我只是想问,你想查什么,既然你都group by c.username了,其他的也并不是聚合计算的字段,你一起group by 了就好了呀
最后一行改成 group by c.username,r.computerid,r.fee
只是这样改了后是你要的结果吗?
更多追问追答
追问
不是,我是想要以UserName来排列
追答
那你原本的最后一行去掉 改成 ORDER BY C.UserName
追问
说错!!!是以UseName来分组
追答
那你的费用列,是不是要进行sum计算呀?
select C.UserName,R.ComputerID,sum(R.fee) from Card as C JOIN Record as R on (C.ID=R.CardID) WHERE DATEDIFF(DW,R.ENDTIME,'2013-06-16')<=7 GROUP BY C.UserName,R.ComputerID
这样看看
追问
结果还是没有进行分组,2和3还是同名
追答
select C.UserName,sum(R.fee)from Card as C JOIN Record as R on (C.ID=R.CardID)WHERE DATEDIFF(DW,R.ENDTIME,'2013-06-16')<=7GROUP BY C.UserName