select count(*) as C_Count, u.fullname ,c.seat_jobnumber,DATEDIFF(ss,call_time,offhook_time) as diff_time from tb_call as c left join tb_user as u on u.username = c.seat_jobnumber where 1=1  and c.call_time >='2012-02-09' and c.call_time <'2012-02-09 23:59:59' group by c.seat_jobnumber,u.fullname,call_time会报错:“列 'c.offhook_time' 在选择列表中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中。”
要怎么改才能达到我想要的这个结果呢?

解决方案 »

  1.   

    因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中
      

  2.   

    select count(*) as C_Count, u.fullname ,c.seat_jobnumber,DATEDIFF(ss,call_time,offhook_time) as diff_time from tb_call as c left join tb_user as u on u.username = c.seat_jobnumber where 1=1  and c.call_time >='2012-02-09' and c.call_time <'2012-02-09 23:59:59'