Rank archive
Guides grouped by the expected difficulty and amount of SQL context they assume.
Extend a table's structure by adding a new column with `ALTER TABLE`.
Compute the arithmetic mean of numeric values across matching rows.
Convert string values to all uppercase or all lowercase using `UPPER` and `LOWER`.
Use `IS NULL` and `IS NOT NULL` to filter rows based on whether a column has a value.
Use `ABS` to strip the sign from a number and `MOD` (or the `%` operator) to get the integer remainder after division.
Strip the time portion from a timestamp so only the calendar date remains.
Change a value from one SQL type to another using an explicit cast.
Audit a table for `NULL` values by counting how many rows have no value in each column of interest.
Aggregate a result set into a single row that reports how many rows matched.
Count only the distinct values in a column, ignoring duplicates.
Define a new table with column names and data types using `CREATE TABLE`.
Permanently remove a table and all its data with `DROP TABLE`.
Remove matching rows with `DELETE`, then query the remaining table contents.
Use `SIGN` to reduce any number to -1, 0, or 1 based on whether it is negative, zero, or positive.
Return components such as year, month, and day from a date or timestamp value.
Define a column default so inserts can omit routine values and still store a complete row.
Match string columns against a wildcard pattern using `LIKE`.
Use `IN` to match a column against a list of values in a single `WHERE` clause.
Return only rows that match a condition, with explicit ordering for stable output.
Use `BETWEEN` to match rows where a column falls within an inclusive lower and upper bound.
Compare normalized text values with LOWER or UPPER so matching does not depend on stored capitalization.
Use a `WHERE` predicate to list rows that already break a business or constraint rule.
Use `MIN` and `MAX` to find the lowest and highest values in a column.
Return the current date and time using `CURRENT_TIMESTAMP` or engine-specific functions.
Return the number of characters in a string using `LENGTH` or `LEN`.
Add new data to a table, then verify the inserted row with a deterministic query.
Add several rows in one statement using a multi-value `INSERT`.
Populate a table by selecting rows from another table using `INSERT INTO ... SELECT`.
Combine multiple text values into one string in the query result.
Combine multiple text values into one hyphen-separated key-like string.
Return only part of a result set using the row-limiting syntax each engine supports.
Inspect a table definition to see its column names and data types.
Inspect the current database or schema to see which tables exist.
Change a column's name in place without dropping or recreating the table or its data.
Use `AS` to give result columns clearer labels without changing the underlying table schema.
Use `REPEAT` to duplicate a string a given number of times, and `REVERSE` to flip its character order.
Return the first non-null value from a list of expressions.
Substitute all occurrences of a substring with a new value using `REPLACE`.
Use `DISTINCT` to remove duplicate rows from a result set.
Use `GREATEST` and `LEAST` to compare multiple values in a single expression without a `CASE WHEN` chain.
Control the precision or snapping of numeric results using `ROUND` for half-up rounding, `CEIL` to round up to the next integer, and `FLOOR` to round down.
Return every row from a table with an explicit sort order for deterministic output.
Include arithmetic, string, or conditional expressions directly in a `SELECT` list and give them an alias with `AS`.
Retrieve a fixed number of rows from the top of a sorted result set using `LIMIT`, `TOP`, or `FETCH FIRST`.
Use more than one sort key so ties are broken deterministically.
Control the order of result rows explicitly instead of relying on storage order.
Add numeric values across matching rows and return one aggregate total.
Remove leading and trailing whitespace from string values with `TRIM`.
`COUNT(column)` skips `NULL` values, while `COUNT(*)` counts every row that made it into the result set.
Modify existing rows with `UPDATE`, then verify the changed data with a stable query.
A row limit without an explicit sort can return different rows over time or across engines.