HAVING without GROUP BY filters the single implicit aggregate group produced by the query. I use that distinction when a summary should appear only if its aggregate condition passes. A false condition can remove the summary row entirely.
CUBE: Include Every Two-Dimensional Subtotal Combination
CUBE requests every grouping combination of its dimensions, including independent subtotals and the grand total. I compare its output population with ROLLUP before choosing it. More subtotal families are useful only when the report needs them.
REPLICATE: Zero Copies and Negative Counts Differ
REPLICATE treats zero copies differently from a negative count. I keep the source and requested count beside the result. Byte lengths and NULL flags reveal several blank-looking outcomes.
Conditional COUNT: ELSE 0 Counts Nonmatching Rows
Conditional COUNT includes zero when CASE returns it. I compare an omitted ELSE with a zero branch before aggregating. A no-match group and an empty input expose the difference from SUM.
GROUPING SETS: Choose Nonhierarchical Subtotals Explicitly
GROUPING SETS lets me choose independent subtotal combinations instead of assuming one hierarchy. I list the groups the report needs explicitly. That can exclude detail rows while retaining summaries across different dimensions.
GROUPING_ID: Separate Stored NULL Values From ROLLUP Totals
GROUPING_ID helps me distinguish a stored NULL from a subtotal created by ROLLUP. Both can appear in the same column. I keep the grouping bits beside the numbers before adding presentation labels.
WINDOW: Reuse an Explicit Running-Total Frame
WINDOW lets me name a window definition and reuse it across compatible calculations. I still specify the partition, ordering and frame. A short name should make the intended calculation easier to review.







