SQL查询指令运用
答案:1 悬赏:0 手机版
解决时间 2021-03-19 05:22
- 提问者网友:姑娘长的好罪过
- 2021-03-18 23:31
SQL查询指令运用
最佳答案
- 五星知识达人网友:夜风逐马
- 2021-03-19 01:04
请试一试:
select a.[商品ID],a.a+isnull(b.bQty,0)-isnull(c.cQty) as [数量],
b.bAll/b.bqty as [进价],
c.cAll/c.bqty as [售价]
from
(select [商品ID],sum(库存数量) as a from [库存表] group by [商品ID] ) a
left join
(select [商品ID],sum(进货数量) as bQty,
sum(进货数量*进价) as bAll
from [进货表] group by [商品ID] ) b
on a.[商品ID] = b.[商品ID]
(select [商品ID],sum(销售数量) as cQty,
sum(销售数量*售价) as cAll
from [销售表] group by [商品ID] ) c
on a.[商品ID] = c.[商品ID]如有疑问,及时沟通!
追问
主要还是对语句不理解吧,不知道如何去修改
谢谢您
select a.[商品ID],a.a+isnull(b.bQty,0)-isnull(c.cQty) as [数量],
b.bAll/b.bqty as [进价],
c.cAll/c.bqty as [售价]
from
(select [商品ID],sum(库存数量) as a from [库存表] group by [商品ID] ) a
left join
(select [商品ID],sum(进货数量) as bQty,
sum(进货数量*进价) as bAll
from [进货表] group by [商品ID] ) b
on a.[商品ID] = b.[商品ID]
(select [商品ID],sum(销售数量) as cQty,
sum(销售数量*售价) as cAll
from [销售表] group by [商品ID] ) c
on a.[商品ID] = c.[商品ID]如有疑问,及时沟通!
追问
主要还是对语句不理解吧,不知道如何去修改
谢谢您
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯