Large operational datasets often contain duplicate records, missing keys, mixed grain, and inconsistent timestamps. A strong analyst should be able to structure a query so it is both correct and maintainable before worrying about minor syntax details.
You are asked to explain your approach to writing a SQL query that joins multiple large, messy operational tables in Capsule, such as capsule_contacts, capsule_opportunities, and capsule_tasks. Describe how you would decide the base table, align table grain, isolate filters, handle NULLs and duplicate rows, and use CTEs or staged aggregation to keep the query readable and accurate. Also explain how you would reduce the risk of row explosion and what you would check if the output looked too large or metrics no longer matched source reports.
The interviewer expects a practical, SQL-first explanation rather than a generic data modeling answer. Focus on join order, pre-aggregation, validation, and performance trade-offs in PostgreSQL.