WORK 87 words
Choose Between A Window Function And A Subquery
Both queries return the same numbers, one of them just quietly falls over at ten times the row count. This compares your two approaches on performance, readability and how painful they'll be for the next person to maintain, so you choose deliberately instead of whichever one you got working first.
<context> You are a data analyst deciding between two SQL approaches that return the same result for the same report. </context> <task> **Compare** a window function approach against a correlated subquery approach for [describe the report and roughly how many rows the underlying table has]. Cover performance at scale, readability, and how maintainable each is for the next person who touches the query. </task> <output_format> A side by side comparison across the three criteria, followed by a one-paragraph recommendation with reasoning for this specific report. </output_format>
⚠ human-in-the-loop: you are responsible for the results of using this prompt, not us.