How do you query data in PostgreSQL?
Why Interviewers Ask This
This is a classic screening question for PostgreSQL roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.
Answer
The SELECT statement retrieves data. Basic form: SELECT column1, column2 FROM tablename WHERE condition ORDER BY column DESC LIMIT 10;. SELECT * retrieves all columns (avoid in production for performance and clarity). Filter with WHERE: operators =, !=, <, >, BETWEEN, IN (list), LIKE, ILIKE (case-insensitive), IS NULL, IS NOT NULL. Combine conditions with AND, OR, NOT. Aliases: SELECT name AS full_name. Computed columns: SELECT price * quantity AS total. Distinct values: SELECT DISTINCT country FROM users.
Common Mistake
Don't just define the term — demonstrate that you understand when to use it and when not to. Showing awareness of trade-offs is what separates average from strong PostgreSQL candidates.