Skip to content
Advertisement

SQL query to find Old clients that have transactions before 2014 but nothing afterwards?

Self-taught beginner here. I want to sort out (old) clients that have last transactions in 2014 but nothing else till date.

I tried this:

but get no result

THEN I tried sorting with excel but even more difficult

I expect the output to be

Advertisement

Answer

If you want clients whose last trade is in 2014, then use aggregation:

If you want information about the last transaction for such accounts, use window functions:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement