Skip to Content
Skip to content
236 results
SQL
Fix "column does not exist" Level: Beginner

Find the cause of the column does not exist error from the five usual ones: a typo, double quotes, an alias in WHERE, a quoted name and a missing table.

SQL
Import a CSV With \copy Level: Beginner

Load a CSV file into a table with the psql command copy, and read the two errors you will meet first. After this, you can import a file without writing INSERT statements.

SQL
Verify a PostgreSQL Practice Database and Its Persistence Level: Beginner

Identify an isolated practice database, record its cluster and marker, and verify persistence through restart and container replacement before exact cleanup.

SQL
Keep Rows With No Match Using LEFT JOIN Level: Beginner

Keep customers who have no orders with LEFT JOIN, find them with IS NULL and avoid the WHERE that turns the join back into an inner join.

SQL
Select Only the Columns You Need Level: Beginner

Replace SELECT * with the columns you need and see what a new column does to a query that uses the star. After this, your saved queries stop changing when the table does.

SQL
Run UPDATE and DELETE in a Transaction First Level: Beginner

Run an UPDATE or DELETE inside a transaction, check the row count and roll back if it is wrong. After this, a missing WHERE no longer costs you the data.

SQL
Why = NULL Returns Nothing Level: Beginner

See why a comparison with NULL returns no rows and fix it with IS NULL, IS DISTINCT FROM or COALESCE. After this, your WHERE clauses stop dropping rows with missing values.

SQL
Add a CHECK Constraint to a Table That Has Data Level: Intermediate

Find the rows that break the rule, fix them, then add the constraint as NOT VALID and validate it.

SQL
Delete Duplicate Rows and Keep One Level: Intermediate

Number the copies with ROW_NUMBER, preview the rows that would go, delete them inside a transaction and add a UNIQUE rule.

SQL
Fix "must appear in the GROUP BY clause" Level: Intermediate

Read the error, then fix it the right way: group by the column, aggregate it or move the aggregate into a subquery. After this, you know which fix keeps your numbers correct.

SQL
Get the Latest Row per Group With DISTINCT ON Level: Intermediate

Keep one row per group in the order you choose with the PostgreSQL DISTINCT ON clause, and compare it with the standard ROW_NUMBER version.