Vol. I · A Postgres HandbookTwelve chapters · · 756 queries

The Query & the Schema

A reading-room reference for writing PostgreSQL by hand — selects to window functions, with the schema in plain view.

FrontChaptersSchemaColophon
Chapters · Basic SELECT · Query 013 / 136
EasyBasic SELECT

Select employees hired in the year 2023

The query

SQL
SELECT first_name, last_name, hire_date
FROM employees
WHERE EXTRACT(YEAR FROM hire_date) = 2023
ORDER BY hire_date;
Tested against PostgreSQL 16

Note

“EXTRACT pulls date parts: YEAR, MONTH, DAY, HOUR, MINUTE, etc.

Tables referenced

  • employees10 cols

← Previous

Show total sum of all product prices in stock

Next →

Show products with stock between 10 and 100

The Query & the Schema

Set in Fraunces and Inter Tight. Printed on parchment, in oxblood and ink. No tracking, no accounts, no JavaScript on the answer pages beyond what your browser needs to copy a query.

Compiled for Postgres 16 · MMXXVI