I have an orders table with USER_ID and ORDER_DATE
I want to achieve somthing like this:
SELECT [USER_ID], [FIRST_ORDER_DATE], [SECOND_ORDER_DATE],
[THIRD_ORDER_DATE], [FOURTH_ORDER_DATE]
FROM ORDERS
I have tried to create a scalar function (getFirstOrder, getSecondOrder, …)
but after the third its very slow
any ideas?
Thanks!
Something like this:
You didn’t specify your DBMS. The above is ANSI SQL that works on most modern DBMS.