These SQL one pagers include every query for the most common SQL queries, all in one page.
The most common DQL (Data Query Language) queries are in one page with a separate 'test yourself' file.
The most common Window functions for more advanced analysis are included in a separate file, with another 'test yourself' file.
sql-dql-queries.ipynb - 11 sections of the most common SQL DQL query examples in one page with clear query aims and notes.
sql-dql-queries-syntax-only.ipynb - Quick syntax guide - only queries
sql-dql-queries-test-yourself.ipynb- Simple query tests. A great way to test your knowledge.
sql-window-functions - 10 most common Window functions for data analysis with SQL. Clear query aims and notes added.
sql-window-functions-test-yourself - Simple query tests. A great way to test your knowledge.
- SQL Query Order
- Sorting - Order by
- Limiting - Offset, Fetch, Select Top
- Filtering - Distinct, And Or In, Between, Like, Column Aliases
- Joins - Inner Join, Left Join, Right Join, Full Outer Join, Cartesian Join, Self Join
- Grouping - Group By, Having, Grouping Sets, Cube, Rollup
- SubQuery - Correlated subquery, Exists, Any, All
- Sets - Union, Union All, Intersect, Except
- Common Table Expressions - CTEs, Recursive CTEs
- Pivot
- Expressions - Case, Coalesce, NullIf
- Cumulative distribution
- Dense Rank
- First Value
- Lag
- Last Value
- Lead
- NTILE
- Percent Rank
- Rank
- Row Number
- If you already know SQL, maybe test your knowledge with the 'test-yourself' files.
- If you are new to SQL, see the links in the related section to setup and download a practice database.
- The queries are here are used (mainly) with the BikeStore database from the sqlservertutorial in the related section.
- SQL Server
- BikeStore Database
-
SQL Server https://docs.microsoft.com/en-us/sql/sql-server/tutorials-for-sql-server-2016?view=sql-server-ver15 https://www.sqlservertutorial.net
-
The topics covered in the DQL (Data Query Language) files are used across all database servers (although the syntax will vary.) The 'test_yourself' files could be used to also check overall knowledge with Postgres and MySQL databases.
-
Postgresql https://www.postgresql.org/docs/8.0/tutorial.html https://www.postgresqltutorial.com/
-
MySQL https://dev.mysql.com/doc/refman/8.0/en/tutorial.html https://www.mysqltutorial.org/