Files
grocy/migrations/0201.sql

10 lines
226 B
MySQL
Raw Normal View History

2022-08-29 20:56:15 +02:00
DROP VIEW products_average_price;
CREATE VIEW products_average_price
AS
SELECT
1 AS id, -- Dummy, LessQL needs an id column
s.product_id,
SUM(s.amount * s.price) / SUM(s.amount) as price
FROM stock s
GROUP BY s.product_id;