これは、ウィンドウ関数を使用して実行できます:
SELECT order_id,
user_id,
orderdat,
row_number() over (partition by user_id order by orderedat ) as orders_so_far
FROM orders
order by user_id, orderdat
これは、ウィンドウ関数を使用して実行できます:
SELECT order_id,
user_id,
orderdat,
row_number() over (partition by user_id order by orderedat ) as orders_so_far
FROM orders
order by user_id, orderdat