Skip to content

Instantly share code, notes, and snippets.

@muminoff
Last active April 3, 2017 13:14
Show Gist options
  • Save muminoff/2f15c35bafb76fd9913de9f627730189 to your computer and use it in GitHub Desktop.
Save muminoff/2f15c35bafb76fd9913de9f627730189 to your computer and use it in GitHub Desktop.
explain analyze
select
count(age) as samples,
case
when age < 20 then 2000
when (age >= 20) and (age < 30) then 2030
when (age >= 30) and (age < 40) then 3040
when (age >= 40) and (age < 50) then 4050
when (age >= 50) and (age < 60) then 5060
when age >= 60 then 6000
else ''
end as age_category
from samples
group by age_category;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment