日期:2014-05-18  浏览次数:20418 次

求一条SQL统计语句
表a(编号ID,数量,仓库ID,库位ID,日期)
仓库表b(仓库ID,仓库NAME)
库位表c(库位ID,库位NAME)
问:   怎么统计表a中某编号的数量,统计出的信息显示:编号,总数量,仓库名称,库位名称?

------解决方案--------------------

select
A.编号id as 编号,
sum(A.数量) as 总数量,
min(B.仓库name) as 仓库名称,
min(C.库位name) as 库位名称
from A
inner join B on A.仓库id=B.仓库id
inner join C on A.库位id=C.库位id
group by A.编号id,A.仓库ID,A.库位id