SQL 语句求助,同时求2个参数的合计
SQL语句如下:
SELECT gdsbs.gdsid,SUM(gdsbs.qty),SUM(gdsbs.amt),后面自己补齐
FROM (你上面的结果集 ) AS gdsbs
GROUP BY gdsbs.gdsid
select gdsbs.prvid
,gdsbs.gdsid
,gds.gdsdes
,gds.spc
,gds.bsepkg
,SUM(gdsbs.qty) AS Qty
,gdsbs.prc
,SUM(gdsbs.amt) AS Amt
FROM bizdep,gdsbs,gds
WHERE ( bizdep.dptid = gdsbs.dptid )
and ( bizdep.depid = gdsbs.depid )
and (gdsbs.fscprdid='1310')
and (gdsbs.dptid like '%')
and (bizdep.savdptid like '602') and
(gdsbs.prvid like '00500') and gdsbs.gdsid in
(select gdsid from gds where clsid like '%%'+'%') and
gdsbs.gdsid=gds.gdsid and qty <> 0
GROUP BY gdsbs.prvid
,gdsbs.gdsid
,gds.gdsdes
,gds.spc
,gds.bsepkg
,gdsbs.prc
order by gdsbs.prvid,gdsbs.gdsid desc
select gdsbs.prvid,gdsbs.gdsid,gds.gdsdes,gds.spc,gds.bsepkg,
sum(gdsbs.qty) 'qty',gdsbs.prc,sum(gdsbs.amt) 'amt'
FROM bizdep,gdsbs,gds
WHERE bizdep.dptid = gdsbs.dptid and
bizdep.depid = gdsbs.depid and gdsbs.fscprdid='1310' and
gdsbs.dptid like '%' and bizdep.savdptid like '602' and
gdsbs.prvid like '00500' and gdsbs.gdsid in
(select gdsid from gds where clsid like '%%'+'%') and
gdsbs.gdsid=gds.gdsid and qty<>0
group by gdsbs.prvid,gdsbs.gdsid,gds.gdsdes,gds.spc,gds.bsepkg,gdsbs.prc
order by gdsbs.prvid,gdsbs.gdsid desc
select gdsbs.prvid,
gdsbs.gdsid,
gds.gdsdes,
gds.spc,
gds.bsepkg,
SUM(gdsbs.qty) AS Qty,
gdsbs.prc,
SUM(gdsbs.amt) AS Amt
FROM bizdep,gdsbs,gds
WHERE ( bizdep.dptid = gdsbs.dptid )
and ( bizdep.depid = gdsbs.depid )
and (gdsbs.fscprdid='1310')
and (gdsbs.dptid like '%')
and (bizdep.savdptid like '602')
and (gdsbs.prvid like '00500')
and gdsbs.gdsid in
(select gdsid from gds
where clsid like '%%'+'%')
and gdsbs.gdsid=gds.gdsid and qty <> 0
GROUP BY
gdsbs.prvid,
gdsbs.gdsid,
gds.gdsdes,
gds.spc,
gds.bsepkg,
gdsbs.prc
order by gdsbs.prvid,gdsbs.gdsid desc