
The purpose of SQL Zen Garden is to provide simple examples of various SQL Server constructs.
"Hello World", "Proof of Concept", whatever you want to call it.
The goal is to reduce the code to only what contributes to illustrate the example.
- SELECT * FROM Table
- Finding duplicates
- DELETE Duplicates using a cte
- Rank & Dense Rank
- UNION ALL (Addition)
- Percent Total
- IN (with SELECT)
- PIVOT
- UnPivot
- Common Table Expression (ROW_NUMBER)
- OVER
- INTERSECT
- Self join
- With Rollup
- Top(1) Percent
- FULL OUTER JOIN
- CROSS JOIN (multiplication)
- Theta Θ join
- Full set difference
- TOP WITH TIES
- Scalar subquery
- Row Constructors
- IN operator with constants
- Nesting aggregations
- ALL
- SOME (ANY)
- correlated subqueries (EXISTS)
- Relational division
- Grouping sets
- Including non-aggregate descriptive columns
- Cube
- Crosstab using CASE
- Cumulative Totals (Running Sums)
- Cumulative Totals (T-SQL cursor solution)
- Multiple rows inserted with 1 insert statement.
- Insert from a stored procedure
- Creating a table with an Insert statement
- Computed Columns
- Cross Apply
- Outer Apply
- CASE
- Boolean CASE
- Check constraint
- EXCEPT
- Update from a second table
- While
- NTILE
- Count(DISTINCT CityName)
- Sum, Avg, Min, Max, Std Deviation, Variance, Count
- Static Function
- FOR XML
- Delete duplicates using primary key value
- Table Variable
- While loop (with break)
Also check out: CFM Zen Garden, and
jQuery Zen Garden.
Database: Phillip Senn
Design: Ryan Carroll