我只想查询出不同的a.p_code的zongji金额,其余的不管相不相同,只要a.p_code不同就作为一条记录显示出来,(要求a.r_pinming, a.r_guige也要显示出来),可用下面的语句只要有一个不同(如 a.r_guige不同),也作为一条记录显示出来,请问sql语句应怎样写???
我的语句如下:select distinct a.p_code,a.r_pinming, a.r_guige,sum(a.r_zongji) zongji,b.s_sh
from report a,sellcard b where a.s_id=b.s_id
我的语句如下:select distinct a.p_code,a.r_pinming, a.r_guige,sum(a.r_zongji) zongji,b.s_sh
from report a,sellcard b where a.s_id=b.s_id
r_guige来显示,但这样不知道能满足你的需要不?