update dedupe logic -> much faster now

This commit is contained in:
Deeman
2025-10-07 22:32:45 +02:00
parent da89c2bf6e
commit 025dda16c6

View File

@@ -10,9 +10,9 @@ MODEL (
SELECT
max(hkey) as hkey,
commodity_code,
commodity_name,
max(commodity_name) as commodity_name,
country_code,
country_name,
max(country_name) as country_name,
ingest_date,
COALESCE(SUM(CASE WHEN attribute_name = 'Production' THEN value END), 0) AS Production,
COALESCE(SUM(CASE WHEN attribute_name = 'Imports' THEN value END), 0) AS Imports,
@@ -47,11 +47,9 @@ WHERE attribute_name IN (
)
GROUP BY
commodity_code,
commodity_name,
country_code,
country_name,
ingest_date
ORDER BY
commodity_name,
country_name,
ingest_date;
commodity_code,
country_code,
ingest_date