group by 分组排序

  1. max(id) 获取分组中最大的ID (最新的记录) 外层根据ID获取完整数据
select 
  q.Id,
  q.asker,
  q.other -- add other columns here
from questions q
inner join
(
  -- get your values from the group by
  SELECT max(id) as id, 
    asker
  FROM questions 
  GROUP by asker 
) m
  on q.id = m.id
order by q.id desc
posted @ 2022-01-19 11:39  Rorchachl  阅读(79)  评论(0)    收藏  举报