#SQL
Notes related to SQL.
131 notes tagged
Realistic Scenarios: Analysis and Optimisation
Six end to end problems of the kind real work produces - a sales report, a retention table, a data quality audit, a duplicate cleanup and two optimisa...
Advanced Practice: Subqueries, CTEs and Window Functions
Twelve harder exercises - correlated subqueries, recursive CTEs, ranking, running totals and top N per group - with solutions and the reasoning behind...
Intermediate Practice: Joins and Aggregation
Fifteen exercises combining joins, grouping and having, each with the solution and a note on the trap it was designed to expose.
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.
Writing Portable SQL
How much portability is worth paying for, which constructs are safe everywhere, and how to isolate the parts that can never be portable.
PostgreSQL, MySQL, SQL Server, Oracle and SQLite Compared
One reference table for the differences that actually break code: paging, auto increment, strings, dates, upserts and the features each product lacks.
Users, Roles, GRANT, REVOKE and Least Privilege
Controlling who can do what: creating users, granting the minimum needed, grouping privileges into roles, and the accounts a typical application actua...
SQL Injection and Parameterised Queries
Why string concatenation lets user input rewrite your query, and why prepared statements make it structurally impossible - with the cases parameters c...