Skip to content

Instantly share code, notes, and snippets.

@gjask
Created November 8, 2016 21:30
Show Gist options
  • Save gjask/a1e6486f505caacc1eabf45cba7f6a19 to your computer and use it in GitHub Desktop.
Save gjask/a1e6486f505caacc1eabf45cba7f6a19 to your computer and use it in GitHub Desktop.
pure SQL PIVOT alternative
select
number_id,
sum(case when gate = 1 then points end) gate1,
sum(case when gate = 2 then points end) gate2,
sum(points) points_total
from check
group by number_id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment