Loading topic
SELECT ... FROM ... WHERE query, sort with ORDER BY, and read a table as rows and columns. The examples use a customers table with columns customer_id, name, country, and city. It also uses an orders table.6 min readSELECT ... FROM query, filter with WHERE, sort with ORDER BY, and that you know what tables, rows, and columns are. It also assumes you have seen single-column SELECT DISTINCT. Here you will learn how DISTINCT behaves when you list several columns5 min readSELECT ... FROM ... WHERE query, sort with ORDER BY, and group rows with GROUP BY. It also assumes you have met SELECT DISTINCT in the previous chapters. The examples use a customers table with customer_id, country, and city columns, and an 7 min readDISTINCT and COUNT(DISTINCT ...) handle NULL. It assumes you can write a basic SELECT ... FROM, filter with WHERE, sort with ORDER BY, and that you know what tables, rows, and columns are. You should also have seen SELECT DISTINCT on one and several columns, and5 min readLIMIT clause: what it does, how it behaves with ORDER BY and WHERE, and where it differs between databases. It assumes you can write a basic SELECT ... FROM query, filter with WHERE, and sort with ORDER BY. You should also know what tables, rows, and columns are.6 min readSELECT ... FROM ... WHERE query, sort with ORDER BY, and that you know a table is made of rows and columns. It also assumes you have met LIMIT as a way to cap the number of returned rows. Here you will learn why LIMIT without ORDER BY gives no rel6 min readOFFSET, the clause that skips rows before LIMIT starts counting. It assumes you can write a SELECT with WHERE and ORDER BY, and that you know LIMIT returns at most N rows. Later chapters cover building complete paged queries, the cost of large offsets, and keyset pagi5 min readSELECT ... FROM ... WHERE, sort with ORDER BY, and that you already know LIMIT restricts the row count and OFFSET skips rows. Here you combine them into a 6 min readSELECT ... FROM ... WHERE query and sort with ORDER BY. It also assumes you know what DISTINCT and LIMIT do on their own. Here the question is when each clause runs. That order explains several errors and surprising results.6 min readSELECT ... FROM ... WHERE queries, sort with ORDER BY, and that you already know what DISTINCT, LIMIT, and OFFSET do on their own. Here you will combine them. The combination is where most real mistakes happen, because the clauses run in a fixed log7 min readOFFSET gets slower as the number grows, how to see that cost in a query plan, and what you can do about it. It assumes you can write SELECT, WHERE, and ORDER BY queries, and that you have already used LIMIT and OFFSET to build a paged query. It also assumes you 6 min readSELECT queries with WHERE and ORDER BY. It also assumes you know LIMIT and OFFSET, and that you have seen why a large OFFSET gets slow. Here you will replace OFFSET with a condition on the sort keys. You will also learn what that costs you.5 min read