From af4715e17fe84e725e1dc81a7f33a3de8a332d0e Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Mon, 29 Aug 2022 20:56:15 +0200 Subject: [PATCH] Fixed product average price rounding --- migrations/0201.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 migrations/0201.sql 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;