select prtnum,sum(qty),stknum,custname1,sum(cost)/sum(qty),sum(amount),username,sx_flag,bal_month from tnxcxview group by prtnum,stknum,custname1,username,sx_flag,bal_month
select prtnum,sum(qty) as qty,stknum,custname1,sum(cost)/sum(qty) as cost,sum(amount) as amount,username,sx_flag,bal_month from tnxcxview group by prtnum,stknum,custname1,username,sx_flag,bal_month
select prtnum,sum(qty) as qty,stknum,custname1,sum(cost)/sum(qty) as cost,sum(amount) as amount,username,sx_flag,bal_month from tnxcxview group by prtnum,stknum,custname1,username,sx_flag,bal_month
原表名:tnxcxview
prtnum qty stknum custname1 cost amount sx_flag bal_month 14785 1 CM-GZ22 广州广百 27.43 27.43 0 2004.09
14790 1 CM-GZ22 广州广百 102.8229 102.82 0 2004.09
16CM 1 CM-GZ22 广州广百 3.9 3.9 0 2004.09
18042 1 CM-GZ22 广州广百 37.09 37.09 0 2004.09
20CM 1 CM-GZ22 广州广百 4.26 4.26 0 2004.09
20CM 1 CM-GZ22 广州广百 4.26 4.26 0 2004.09
28CM 1 CM-GZ22 广州广百 6.92 6.92 0 2004.09
54128 1 CM-GZ22 广州广百 9.14 9.14 0 2004.09
54128 1 CM-GZ22 广州广百 9.14 9.14 0 2004.09
54128 1 CM-GZ22 广州广百 9.14 9.14 0 2004.09
54128 1 CM-GZ22 广州广百 9.14 9.14 1 2004.09
54128 1 CM-GZ22 广州广百 9.14 9.14 1 2004.09
54128 2 CM-GZ22 广州广百 9.14 18.28 1 2004.09
54128 1 CM-GZ22 广州广百 9.14 9.14 1 2004.09
54130 1 CM-GZ22 广州广百 10.08 10.08 1 2004.09
54130 1 CM-GZ22 广州广百 10.00 10.00 1 2004.09
54130 1 CM-GZ22 广州广百 10.08 10.08 1 2004.09
想得出下表内容:
prtnum qty stknum custname1 cost amount sx_flag bal_month 14785 1 CM-GZ22 广州广百 27.43 27.43 0 2004.09
14790 1 CM-GZ22 广州广百 102.8229 102.82 0 2004.09
16CM 1 CM-GZ22 广州广百 3.9 3.9 0 2004.09
18042 1 CM-GZ22 广州广百 37.09 37.09 0 2004.09
20CM 2 CM-GZ22 广州广百 4.26 8.52 0 2004.09
28CM 1 CM-GZ22 广州广百 6.92 6.92 0 2004.09
54128 3 CM-GZ22 广州广百 9.14 27.42 0 2004.09
54128 5 CM-GZ22 广州广百 9.14 45.7 1 2004.09
54130 3 CM-GZ22 广州广百 10.53 31.6 1 2004.09
求各位高手指点!
54128 5 CM-GZ22 广州广百 9.14 45.7 1 2004.09
group by prtnum,stknum,custname1,username,sx_flag,bal_month