Beginner Practice Queries
Twenty graded exercises on SELECT, filtering, sorting and simple functions, each with a worked solution and the reason it is written that way.
Reading data with SELECT.
9 notes tagged
Twenty graded exercises on SELECT, filtering, sorting and simple functions, each with a worked solution and the reason it is written that way.
A view is a stored query you can select from like a table. Learn CREATE VIEW, how views are executed, and the four jobs they do well.
A CTE names a query so the rest of the statement can read it like a table. Learn single and chained CTEs, and when a CTE beats a subquery or a view.
GROUP BY collapses rows into one row per distinct key. Learn the single rule that governs the select list and how NULLs are grouped.
Sorting on one or many columns, NULL placement, and the four dialect specific ways to fetch page two of a result set - including why OFFSET gets slow.
Compute values in the select list, build derived columns from existing ones, and use DISTINCT correctly - including what it does across several column...
The statement you will write more than all the others combined. Choose columns, alias them, and learn why SELECT * belongs in the console and not in c...
Arithmetic, comparison, logical, string and set operators, how precedence works, and where an expression may legally appear.
How a SQL statement is built: clause order, keywords versus identifiers, quoting rules, statement terminators and the two comment styles.