Skip to content

Instantly share code, notes, and snippets.

@tarnagas
Created August 16, 2017 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarnagas/f08765b122e8eab46b0c966647b64895 to your computer and use it in GitHub Desktop.
Save tarnagas/f08765b122e8eab46b0c966647b64895 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment