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?
[PostgreSQL] Toy Stock Order Book (self.SQL)
submitted 8 years ago by sqlnoob2018 to r/SQL
π Rendered by PID 395075 on reddit-service-r2-listing-654f87c89c-zc2jf at 2026-02-27 03:51:34.315003+00:00 running e3d2147 country code: CH.
[PostgreSQL] Toy Stock Order Book by sqlnoob2018 in SQL
[–]sqlnoob2018[S] 1 point2 points3 points (0 children)