Link: SQL

Order by

  • ORDER BY: usually put it at the end of query
  • By default it’s ascending
SELECT * FROM pets
ORDER BY Animal DESC, name ASC

LIMIT

  • LIMIT x: limit output
  • Often combine with ORDER BY, such as top x in things

OFFSET

OFFSET x: skip the first x

E.g. Skip first 10 rows and start from the 11th

SELECT * FROM callers
ORDER BY call_received DESC
OFFSET 10
LIMIT 5;

EXTRACT

  • EXTRACT() from Dates
    -- Extract day value from Date column
    SELECT Name, EXTRACT(DAY from Date) AS Day

*