Recursive CTEs: Walking an Org Chart of Unknown Depth
WITH RECURSIVE for hierarchies, generating continuous date ranges, and how to avoid infinite loops.
Recursive CTEs: Walking an Org Chart of Unknown Depth Đọc thêm »
WITH RECURSIVE for hierarchies, generating continuous date ranges, and how to avoid infinite loops.
Recursive CTEs: Walking an Org Chart of Unknown Depth Đọc thêm »
Computing medians, percentiles and buckets with NTILE, PERCENTILE_CONT and PERCENT_RANK in SQL.
Average Salary Is 5,250 While Three of Four People Earn Under 5,000 Đọc thêm »
Running totals, moving averages and the ROWS BETWEEN frame — the three pieces behind every trend chart.
Add ORDER BY and Your SUM Means Something Completely Different Đọc thêm »
LAG reads the previous row, LEAD the next. Growth calculations, gaps between purchases, and the first-row trap.
LAG and LEAD: Removing the Self-Join From Every Growth Report Đọc thêm »
Getting the Nth highest value with DENSE_RANK, how it differs from RANK and ROW_NUMBER, and handling fewer than N values.
Second Highest Salary: An Interview Question With Four Wrong Answers Đọc thêm »
COALESCE returns the first non-NULL value; NULLIF turns a value into NULL. Used correctly they also prevent divide-by-zero.
COALESCE and NULLIF: Two Functions That Clean Up Every Blank Cell Đọc thêm »
Choosing between IN, EXISTS and JOIN for existence checks, plus the NULL trap that empties NOT IN.
EXISTS or IN? The Right Answer Runs 30 Times Faster Đọc thêm »