分組,並計算每組的庫存量的sql查詢語句
select
a.GroupID AS c1,
a.Brand AS c2,
a.CPU AS c3,
a.DRAM AS c4,
a.HD AS c5,
a.CDDriver AS c6,
a.LCD AS c7,
a.BlueTooth AS c8,
a.Camera AS c9,
a.Price AS c10,
b.num as c11 from goods a inner join
(select min(goodid) as goodid,sum(num) as num from goods
where Status=1
and( Brand like @parm_Brand+'%'
and Price between @parm_val1 and @parm_val2)
group by groupid)b
on a.goodid=b.goodid
ORDER BY c1, c2
a.GroupID AS c1,
a.Brand AS c2,
a.CPU AS c3,
a.DRAM AS c4,
a.HD AS c5,
a.CDDriver AS c6,
a.LCD AS c7,
a.BlueTooth AS c8,
a.Camera AS c9,
a.Price AS c10,
b.num as c11 from goods a inner join
(select min(goodid) as goodid,sum(num) as num from goods
where Status=1
and( Brand like @parm_Brand+'%'
and Price between @parm_val1 and @parm_val2)
group by groupid)b
on a.goodid=b.goodid
ORDER BY c1, c2