Skip to content

Instantly share code, notes, and snippets.

@awmpietro
Created June 28, 2017 20:04
Show Gist options
  • Select an option

  • Save awmpietro/fbee8293b1a53d95b30f55e2244ab314 to your computer and use it in GitHub Desktop.

Select an option

Save awmpietro/fbee8293b1a53d95b30f55e2244ab314 to your computer and use it in GitHub Desktop.
Group a count of values in specific label
SELECT
(case when field not in('value1', 'value2') then 'OUTROS'
when field in('value3') then 'value3'
count(est_des_descricao) as total
FROM
tables
GROUP BY
field DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment