问题栏

用户名:xx01

悬赏金:40鼠币

达梦数据库的group by 语句出错

select shop.ID as 主键,shop.UID as 用户id,test.NAME as 姓名 from sysdba.T shop
left join sysdba.TEST test on shop.ID = test.ID
where shop.ID > 0
group by test.NAME;
加上group by 就报错 :无效的select项

发布时间:2019-04-17
解答栏
  • 用户名:MASHEN

    select max(shop.ID) as 主键,max(shop.UID) as 用户id,test.NAME as 姓名 from sysdba.T shop
    left join sysdba.TEST test on shop.ID = test.ID
    where shop.ID > 0
    group by test.NAME;
    或者
    select shop.ID as 主键,shop.UID as 用户id,test.NAME as 姓名 from sysdba.T shop
    left join sysdba.TEST test on shop.ID = test.ID
    where shop.ID > 0
    group by test.NAME,shop.ID,shop.UID

    发布时间:2019-04-17



撰写答案
请登录后再回答