聚合函數(shù)不使用group by 分組只會(huì)查詢出一條結(jié)果
使用group by 分組后會(huì)統(tǒng)計(jì)不同組別的數(shù)量
select b.STATUS as status,count(distinct(a.BUYER_NICK)) as count,cast(sum(a.PAYMENT) as decimal(15,2)) as payCount
from DT_SMS_EFFECT as a inner join DT_TRADE_INFO as b on(a.USER_ID = b.USER_ID and a.TREAD_ID = b.TRADE_ID)
where a.USER_ID = ? and a.GMT_SMS_SEND > ? and a.PAYTIME >= ? group by status