Aggregate functions in WHERE clause in SQLite

后端 未结 4 1735
青春惊慌失措
青春惊慌失措 2021-02-08 06:29

Simply put, I have a table with, among other things, a column for timestamps. I want to get the row with the most recent (i.e. greatest value) timestamp. Currently I\'m doing th

4条回答
  •  半阙折子戏
    2021-02-08 06:50

    SELECT * from foo where timestamp = (select max(timestamp) from foo)
    

    or, if SQLite insists on treating subselects as sets,

    SELECT * from foo where timestamp in (select max(timestamp) from foo)
    

提交回复
热议问题