database: Organic update
This commit is contained in:
@@ -61,7 +61,7 @@ SELECT d.year, d.mgnr,
|
||||
d.sortid || b.discr AS bucket,
|
||||
d.sortid, IIF(b.discr IN ('', '_'), NULL, b.discr) AS attrid,
|
||||
SUM(b.value) AS weight,
|
||||
b.discr != '_' AS gebunden
|
||||
b.discr != '_' AS contracted
|
||||
FROM v_delivery d
|
||||
LEFT JOIN delivery_part_bucket b ON (b.year, b.did, b.dpnr) = (d.year, d.did, d.dpnr)
|
||||
GROUP BY d.year, d.mgnr, bucket
|
||||
@@ -71,13 +71,13 @@ ORDER BY d.year, d.mgnr, bucket;
|
||||
CREATE VIEW v_payment_bucket AS
|
||||
SELECT year, mgnr, bucket, weight
|
||||
FROM v_payment_bucket_strict
|
||||
WHERE attrid IS NOT NULL OR NOT gebunden
|
||||
WHERE attrid IS NOT NULL OR NOT contracted
|
||||
UNION ALL
|
||||
SELECT b.year, b.mgnr, b.sortid,
|
||||
SUM(b.weight) AS weight
|
||||
FROM v_payment_bucket_strict b
|
||||
LEFT JOIN wine_attribute a ON a.attrid = b.attrid
|
||||
WHERE gebunden AND (a.strict IS NULL OR a.strict = FALSE)
|
||||
WHERE contracted AND (a.strict IS NULL OR a.strict = FALSE)
|
||||
GROUP BY b.year, b.mgnr, b.sortid
|
||||
ORDER BY year, mgnr, bucket;
|
||||
|
||||
@@ -96,7 +96,7 @@ FROM v_under_delivery_bucket_strict u
|
||||
LEFT JOIN v_payment_bucket_strict p ON (p.year, p.mgnr, p.sortid) = (u.year, u.mgnr, u.bucket) AND p.attrid IS NOT NULL
|
||||
LEFT JOIN wine_attribute a ON a.attrid = p.attrid
|
||||
LEFT JOIN v_area_commitment_bucket_strict s ON (s.year, s.mgnr, s.bucket) = (p.year, p.mgnr, p.bucket)
|
||||
WHERE (p.gebunden IS NULL OR p.gebunden) AND (a.strict IS NULL OR a.strict = FALSE)
|
||||
WHERE (p.contracted IS NULL OR p.contracted) AND (a.strict IS NULL OR a.strict = FALSE)
|
||||
GROUP BY u.year, u.mgnr, u.bucket
|
||||
ORDER BY u.year, u.mgnr, u.bucket;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user