How to group by DESC order

后端 未结 7 1960
终归单人心
终归单人心 2020-12-03 06:30

I have the following table called questions:

ID | asker 
1  | Bob
2  | Bob
3  | Marley

I want to select each asker only once and if there are

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-03 07:18

    Normally MySQL allows group by ascending order records only. So we can order records before grouping.

    SELECT *
    FROM (
      SELECT *
      FROM questions
      ORDER BY id DESC
    ) AS questions
    GROUP BY questions.asker
    

提交回复
热议问题