当前位置: 代码迷 >> Sql Server >> 通常group by 后面带多少个字段
  详细解决方案

通常group by 后面带多少个字段

热度:97   发布时间:2016-04-27 11:17:09.0
一般group by 后面带多少个字段?
select UserID,max(CreateON) as CreateOn from 文章表
group by UserID


如果还要多个字段
应该在group by后面加不?
还是嵌套两个select?

------解决方案--------------------
看你的语句可以试试

SQL code
--1select * from 文章表 a where not exists(select 1 from 文章表 where UserID=a.UserID and CreateON>a.CreateON)--2select * from 文章表 a where CreateON=(select max(CreateON) from 文章表 where UserID=a.UserID )
  相关解决方案