求:取重复记录中有数据的那条
name,charge,date
姓名,费用,日期
username1,0,2012-04-01
username1,10,2012-04-01
username1,0,2012-04-01
username2,0,2012-04-01
username2,0,2012-04-01
username2,20,2012-04-01
想把今天的给取出来:
结果如下:
username1,10
username2,20
------解决方案--------------------
要求1次说完,数据要有代表性
select 姓名,sum(费用),日期 from tt group by 姓名,日期 having count(*)>=4 and sum(费用)>0