diff --git a/migrations/0201.sql b/migrations/0201.sql new file mode 100644 index 00000000..2f55fa71 --- /dev/null +++ b/migrations/0201.sql @@ -0,0 +1,9 @@ +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;