Set Operations and Complex Aggregations Questions
Understanding UNION, UNION ALL, EXCEPT, INTERSECT operations and their performance implications. Complex GROUP BY queries, HAVING clauses, and multi-level aggregations.
HardTechnical
61 practiced
In a geo-distributed system with eventual consistency, implementing EXCEPT and INTERSECT semantics across shards can produce surprising results. Describe the correctness challenges when rows are duplicated or partially replicated across regions, and propose strategies to get deterministic set operation results for BI use cases.
EasyTechnical
82 practiced
Provide an efficient SQL pattern to merge two aggregated result sets and add a column to indicate the source of each aggregate. For example, aggregate daily revenue from online_sales and offline_sales, then UNION ALL them with a source column named channel. Include schema examples and explain why UNION ALL is preferable here.
MediumTechnical
109 practiced
What happens if you use ORDER BY and LIMIT inside each branch of a UNION and then UNION those branches together? Explain the SQL standard behavior and common pitfalls when trying to limit rows per branch versus limiting the final result, and provide a correct approach to fetch top M rows per unioned group.
EasyTechnical
66 practiced
Describe INTERSECT and EXCEPT (or MINUS) set operations in SQL and provide a realistic BI example using orders_2023(order_id, customer_id) and orders_2024(order_id, customer_id). Explain when to use INTERSECT and when to use EXCEPT to identify returning customers and lost customers, and discuss how NULLs and duplicate rows affect results.
HardTechnical
65 practiced
Explain HyperLogLog (HLL) mergeability and how it enables approximate distinct counts across unioned partitions or pre-aggregated daily sketches. As a BI analyst, describe how you would integrate HLL into daily pipeline to provide approximate distinct user counts for dashboards and how to convey accuracy to stakeholders.
Unlock Full Question Bank
Get access to hundreds of Set Operations and Complex Aggregations interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.