日期:2014-05-18  浏览次数:20643 次

求高手帮忙写一条select语句
有一张表(offertable)数据如下:
offertime offerpact offercom baletype stoID balenumber baleprice offersum remark
2007-10-10 00:00:00 AK3580 华发 mp3-5 sk550 50 23.50 1175.00 无
2007-10-10 00:00:00 AK3581 华发 mp3-6 sk551 35 25.50 892.50 无
2007-10-10 00:00:00 AK3582 华发 mp4-1 sk552 70 45.00 3150.00 无
2007-10-10 00:00:00 AK3583 盛开 mp3-5 sk553 52 12.80 665.60 无
2007-10-10 00:00:00 AK3584 盛开 mp3-6 sk554 45 75.50 3397.50 无
2007-10-10 00:00:00 AK3585 盛开 mp4-1 sk555 75 45.80 3435.00 无
2007-10-10 00:00:00 AK3586 华发 mp3-5 sk556 28 24.50 686.00 无
2007-10-10 00:00:00 AK3587 盛开 mp4-1 sk557 45 57.60 2592.00 无
2007-10-12 00:00:00 AK3588 宏阔 mp4-4 sk558 56 57.80 3236.80 无
2007-10-12 10:08:00 AK3589 宏阔 mp4-5 sk559 56 57.80 3236.80 无
现在要求得到下面结果(对产品按不同厂家,不同规格分别总汇)
offercom baletype balenumber offersum
华发 mp3-5 78 1861.00
华发 mp3-6 35 892.50
华发 mp4-1 70 3150.00
盛开 mp3_5 52 665.60
盛开 mp3-6 45 3397.50
盛开 mp4-1 120 6027.00
宏阔 mp4-4 56 3236.80
宏阔 mp4-5 56 3236.80

请各位高手为我指点指点小弟在线等了


------解决方案--------------------
select offercom,baletype,sum(balenumber) balenumber, sum(balenumber*baleprice) offersum
from tb
group by offercom,baletype
------解决方案--------------------
select offercom,baletype,balenumber=sum(balenumber),
offersum=sum(offersum)
from offertable group by offercom,baletype 




我对新版真的无语了...........................................
等半天回答框才出来