Aggregate functions in WHERE clause in SQLite

后端 未结 4 1673
青春惊慌失措
青春惊慌失措 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:52

    There are many ways to skin a cat.

    If you have an Identity Column that has an auto-increment functionality, a faster query would result if you return the last record by ID, due to the indexing of the column, unless of course you wish to put an index on the timestamp column.

    SELECT * FROM TABLE ORDER BY ID DESC LIMIT 1
    

提交回复
热议问题