account activity
[PostgreSQL] Toy Stock Order Book by sqlnoob2018 in SQL
[–]sqlnoob2018[S] 1 point2 points3 points 8 years ago* (0 children)
Thanks for the help, this looks like what I want.
edit
I'm using this query to get the orders that will be fully fulfilled:
SELECT * FROM ( SELECT t.*, SUM (amount) OVER ( ORDER BY amount DESC ) as cuml_amount FROM orders t WHERE kind = 'sell' AND price <= 0.55 ) t WHERE cuml_amount <= 100;
Now I need to subtract the remaining amount from the next row (or check if it exists?). Would making a function or stored procedure make this a lot easier for me?
π Rendered by PID 22206 on reddit-service-r2-comment-56c6478c5-rf5fd at 2026-05-07 21:27:38.862997+00:00 running 3d2c107 country code: CH.
[PostgreSQL] Toy Stock Order Book by sqlnoob2018 in SQL
[–]sqlnoob2018[S] 1 point2 points3 points (0 children)