表一 landscaper_plant
lnum pnum instock
1 A 4
2 B 3
2 C 2
3 A 1
3 C 5
表二 landscaper
lnum landscaper
1 SUNFLOWER
2 RISE
3 XSCAPER
现在要列出的是各店的植物数量总和和店名称这两项,我这样写就报错了
select landscaper,(select sum(instock) from landscaper_plant group by lnum)
from landscaper l,landscaper_plant lp
where l.lnum=lp.lnum
为啥呢?应该怎么写,谢谢
sql 两个表sum问题
答案:2 悬赏:0 手机版
解决时间 2021-02-21 08:11
- 提问者网友:最爱你的唇
- 2021-02-20 19:35
最佳答案
- 五星知识达人网友:春色三分
- 2021-02-20 20:12
select b.landscaper,sum(a.instock)
from landscaper_plant a,landscaper b where a.lnum=b.lnum
group by b.landscaper
from landscaper_plant a,landscaper b where a.lnum=b.lnum
group by b.landscaper
全部回答
- 1楼网友:老鼠爱大米
- 2021-02-20 21:18
select distinct ((select sum(barcodee) from a where billtype=4)-(select sum(barcodee ) from a where billtype=5)) as qty from a
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯