Skip to content

Instantly share code, notes, and snippets.

@tarnagas
tarnagas / sample-count-grouped.sql
Created August 16, 2017 09:49
sample count grouped sql
SELECT *, (
case when sku = 'W556B' then 1 else 0 end +
case when product_type = 'Tapis' then 1 else 0 end
) as cnt from etl_raw_import_art
WHERE (sku = 'W556B' or product_type = 'Tapis')
order by
case when sku = 'W556B' then 1 else 0 end +
case when product_type = 'Tapis' then 1 else 0 end
DESC