select tt.id,tt.userid,tt.begindate,tt.enddate,tt.places,tt.reason,tt.abroad,tt.info1,tt.info2,tt.info3,tt.info4,tt.info5,tt.dept from (select id,userid,begindate,enddate,places,reason,abroad,info1,info2,info3,info4,info5,dept from yjb_evection order by begindate asc) as tt group by tt.userid这是我的sql语句,先按照userid分组,然后在每个分组中安装begindate排序,老是报错提示说命令未正确结束

解决方案 »

  1.   

    楼主完全没有搞明白 分组的意思,,
    在你的sql里面出现了group by 却没有出现相应的分组函数,比如max,min等。
      

  2.   

    一 as 只能给字段起别名,不能给表起别名,这就是命令未正确结束的原因
    二 sql语句里面没有聚合函数,为什么要用到group by 呢?
    三 我认为“order by userid,begindate” 就可以满足你的需求了