>
>
> Try:
>
> bdteste=# SELECT o1.user_id, o1.order_id, '>= 500' AS cond FROM Orders o1
> bdteste-# WHERE (SELECT sum(o2.amount_paid) FROM Orders o2 WHERE
> o2.user_id = o1.user_id AND o2.order_id > o1.order_id) < 500 AND
> bdteste-#(SELECT sum(o2.amount_paid) FROM Orders o2 WHERE
> o2.us
yes, I am picking up the specific transaction (order_id) so that I can
pickup the create_timestamp and sort it descending.
that will list me those users who did transaction more than 500 in the least
time.
then I can give discount for top 10 users
expected output: user_id, create_timestamp(desc) wi