You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WITH regional_sales AS (SELECT region, SUM(sales_amount) as total_sales FROM sales GROUP BY region) SELECT*FROM regional_sales;
2
+
3
+
WITH regional_sales AS (SELECT region, SUM(sales_amount) as total_sales FROM sales GROUP BY region), top_regions AS (SELECT region FROM regional_sales WHERE total_sales >1000000) SELECT*FROM top_regions;
4
+
5
+
WITH RECURSIVE employee_hierarchy AS (SELECT id, name, manager_id, 1as level FROM employees WHERE manager_id IS NULLUNION ALLSELECTe.id, e.name, e.manager_id, eh.level+1FROM employees e JOIN employee_hierarchy eh ONe.manager_id=eh.id) SELECT*FROM employee_hierarchy;
6
+
7
+
WITH sales_summary AS (SELECT region, product_category, SUM(amount) as total FROM sales GROUP BY region, product_category), regional_totals AS (SELECT region, SUM(total) as region_total FROM sales_summary GROUP BY region) SELECTs.region, s.product_category, s.total, r.region_totalFROM sales_summary s JOIN regional_totals r ONs.region=r.region;
0 commit comments