View ColdFusion Source code
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.
  1. SELECT * FROM Table
  2. Finding duplicates
  3. DELETE Duplicates using a cte
  4. Rank & Dense Rank
  5. UNION ALL (Addition)
  6. Percent Total
  7. IN (with SELECT)
  8. PIVOT
  9. UnPivot
  10. Common Table Expression (ROW_NUMBER)
  11. OVER
  12. INTERSECT
  13. Self join
  14. With Rollup
  15. Top(1) Percent
  16. FULL OUTER JOIN
  17. CROSS JOIN (multiplication)
  18. Theta Θ join
  19. Full set difference
  20. TOP WITH TIES
  21. Scalar subquery
  22. Row Constructors
  23. IN operator with constants
  24. Nesting aggregations
  25. ALL
  26. SOME (ANY)
  27. correlated subqueries (EXISTS)
  28. Relational division
  29. Grouping sets
  30. Including non-aggregate descriptive columns
  31. Cube
  32. Crosstab using CASE
  33. Cumulative Totals (Running Sums)
  34. Cumulative Totals (T-SQL cursor solution)
  35. Multiple rows inserted with 1 insert statement.
  36. Insert from a stored procedure
  37. Creating a table with an Insert statement
  38. Computed Columns
  39. Cross Apply
  40. Outer Apply
  41. CASE
  42. Boolean CASE
  43. Check constraint
  44. EXCEPT
  45. Update from a second table
  46. While
  47. NTILE
  48. Count(DISTINCT CityName)
  49. Sum, Avg, Min, Max, Std Deviation, Variance, Count
  50. Static Function
  51. FOR XML
  52. Delete duplicates using primary key value
  53. Table Variable
  54. While loop (with break)

Also check out: CFM Zen Garden, and jQuery Zen Garden.

Database: Phillip Senn
Design: Ryan Carroll