level 1
有两个表,a表有xh,xm,lxnd;b表有xh,xmdm,sjje,b表xh有多条记录,要求查询显示xh,xm,sjje按xh显示sum(sjje) where lxnd=值
2024年10月22日 07点10分
1
level 1
select a.xh,xm,sum(sjje) from
(select xh,xm,lxnd from a ) a
left join
(select xh,xmdm,sjje from b ) b
on a.xh = b.xh
where lxnd = '值'
order by a.xh,xm
2024年10月24日 00点10分
3
level 1
select a.xh,a.xm,b.sjje from a
join
(select xh,sum(sjje) as sjje from b group by xh) as b on a.xh=b.xh
2024年11月12日 09点11分
5
把B表的sjje字段根据xh分类汇总后作为数据源去和A表join,where条件自己加一下就行了
2024年11月12日 09点11分