All jobs / Data analyst / BI / SQL

Data analyst / BI interview question · 1–3 years

You need each order and the customer’s lifetime total on the same row. What do you use?

The strongest answer

A window sum partitioned by customer — I do not join the table to an aggregate of itself if a window is clearer, and I do not GROUP BY and lose the order grain

Why it works

Exactly. Windows keep the grain and add a measure. GROUP BY collapses it.

What a good answer covers

Answers that fall short

Who gets asked this

More SQL questions