1st Row in Group By vs. Last Row

后端 未结 5 771
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-21 10:23

Wondering how to return the 1st row in a MySQL group by vs. the last row. Returning a series of dates, but need the first one displayed.

select * from calendar w         


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-21 10:58

    If you want to show the first AND the last element of a group-by statement, this was useful for me:

    SELECT min(date) AS minn, max(date) AS maxx 
    FROM table_name
    GROUP BY occasion
    

    Thanks for the question

提交回复
热议问题