SQL: Select most recent date for each category

后端 未结 4 888
攒了一身酷
攒了一身酷 2020-12-09 16:21

I\'m pulling data from a database and one of the tables contain two columns that together identify a location and another column containing a date of each time it was servic

4条回答
  •  自闭症患者
    2020-12-09 17:09

    SELECT
        category_a,
        category_b,
        MAX(date)
    FROM
        Some_Unnamed_Table
    GROUP BY
        category_a,
        category_b
    ORDER BY
        category_a,
        category_b
    

    I certainly don't mind helping people when I can, or I wouldn't be on this site, but did you really search for an answer for this before posting?

提交回复
热议问题