Default to last purchased price and quantity when adding transaction item
This commit is contained in:
@ -0,0 +1,14 @@
|
||||
CREATE OR REPLACE VIEW item_purchases AS
|
||||
SELECT
|
||||
item_id,
|
||||
transaction_id,
|
||||
created_at,
|
||||
store_id,
|
||||
price,
|
||||
quantity,
|
||||
CASE ROW_NUMBER() OVER (PARTITION BY item_id ORDER BY created_at DESC)
|
||||
WHEN 1 THEN true
|
||||
ELSE false
|
||||
END AS is_last_purchase
|
||||
FROM transaction_items
|
||||
JOIN transactions USING (transaction_id);
|
Reference in New Issue
Block a user