SQLDAXExcelPython
Leaderboard
Window functionsMedium20 points

Days between first and last order

For each customer with sales, return CustomerId, their first OrderDate, their last OrderDate, and the number of days between the two.

Show solutionLifetime

Runs in your browser with DuckDB, whose SQL is close to PostgreSQL. Nothing you type is sent to a server unless you save a score.

SQLselect text to run only that part
Loading editor…

Press Ctrl+Enter or Run to see the result here.