Skip to content

Instantly share code, notes, and snippets.

@laod
Created August 9, 2012 14:36
Show Gist options
  • Save laod/3304707 to your computer and use it in GitHub Desktop.
Save laod/3304707 to your computer and use it in GitHub Desktop.
We don't need no steenking pivot
create temp view tv2 as select
b.did as id,
(select a.value from namevalue as a where a.name='first' and
a.did=b.did) as first,
(select a.value from namevalue as a where a.name='last' and
a.did=b.did) as last,
(select a.value from namevalue as a where a.name='uid' and
a.did=b.did) as uid,
(select a.value from namevalue as a where a.name='displayname' and
a.did=b.did) as displayname,
(select lower(a.value) from namevalue as a where a.name='displayname' and
a.did=b.did) as lowername
from
(select did from namevalue group by did) as b ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment