请教:把某一个表里相同时间,相同用户名的记录合并为一条记录取出(金额合计),用户名相同时间不同的就还是原样取出。表名:tab_name
id 唯一
name 姓名
time 时间
money 费用

解决方案 »

  1.   

    select name,time,sum(money) from tt group by name,time
      

  2.   

    select name,time,sum(money)
    from tab_name
    group by name,time
      

  3.   

    select name,date_format(time,'%Y-%m-%d'),sum(money) from tt group by name,date_format(time,'%Y-%m-%d')
      

  4.   

    select name,date(time),sum(money)
    from tab_name
    group by name,date(time)
      

  5.   

    #1140 - Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause