- Find duplicate transactions
Use GROUP BY transaction_id HAVING COUNT(*) > 1.
-
Find inactive customers
Find customers with no orders in last 6 months.
-
Find repeat customers
Group by customer and filter COUNT(order_id) > 1.
-
Find one-time customers
Group by customer and filter COUNT(order_id) = 1.
-
Find top-selling products
Group by product and order by total quantity sold desc.
-
Find least-selling products
Group by product and order by total quantity sold asc.
-
Find average order value
SUM(order_amount) / COUNT(order_id).
-
Find monthly revenue
Group by month and sum order amount.
-
Find YoY sales growth
Compare current year sales with previous year sales.
-
Find MoM sales growth
Use LAG() on monthly sales.
-
Find customer lifetime value
Sum total purchase amount by customer.
-
Find customer churn
Find customers with no recent activity.
-
Find best performing region
Group by region and sort by sales desc.
-
Find worst performing region
Group by region and sort by sales asc.
-
Find null-heavy columns
Use COUNT(*) - COUNT(column).
-
Find bad quality records
Check NULLs, duplicates, invalid formats.
-
Find orphan records
Use LEFT JOIN and filter unmatched child records.
-
Validate source vs target count
Compare COUNT(*) from both tables.
-
Find changed records in ETL
Compare source and target using hash/timestamp.
-
Find load failures in ETL
Check audit table, rejected rows, and error logs.