Do not use bio as attribute

This commit is contained in:
2024-02-19 21:58:28 +01:00
parent 977509fbe6
commit 0bbad83b75
6 changed files with 45 additions and 27 deletions

View File

@ -33,24 +33,25 @@ ORDER BY year, mgnr, bucket;
CREATE VIEW v_delivery_bucket_strict AS
SELECT year, mgnr,
sortid || IIF(min_quw, COALESCE(attrid, ''), '_') AS bucket,
sortid, IIF(min_quw, attrid, NULL) AS attrid,
sortid || IIF(min_quw OR NOT COALESCE(area_com, TRUE), COALESCE(a.attrid, ''), '_') AS bucket,
sortid, IIF(min_quw OR NOT COALESCE(area_com, TRUE), a.attrid, NULL) AS attrid,
SUM(weight) AS weight,
min_quw
FROM v_delivery
min_quw OR NOT COALESCE(area_com, TRUE) AS valid
FROM v_delivery d
LEFT JOIN v_wine_attribute a ON a.attrid = d.attrid
GROUP BY year, mgnr, bucket
ORDER BY year, mgnr, bucket;
CREATE VIEW v_delivery_bucket AS
SELECT year, mgnr, bucket, weight
FROM v_delivery_bucket_strict
WHERE attrid IS NOT NULL OR NOT min_quw
WHERE attrid IS NOT NULL OR NOT valid
UNION ALL
SELECT b.year, b.mgnr, b.sortid,
SUM(b.weight) AS weight
FROM v_delivery_bucket_strict b
LEFT JOIN wine_attribute a ON a.attrid = b.attrid
WHERE min_quw AND (a.strict IS NULL OR a.strict = FALSE)
WHERE valid AND (a.strict IS NULL OR a.strict = FALSE)
GROUP BY b.year, b.mgnr, b.sortid
ORDER BY year, mgnr, bucket;