Skip to content

Instantly share code, notes, and snippets.

@robindegen
Created June 8, 2020 15:27
Show Gist options
  • Save robindegen/60a3d24ae02899b86b2f3e2abff5b518 to your computer and use it in GitHub Desktop.
Save robindegen/60a3d24ae02899b86b2f3e2abff5b518 to your computer and use it in GitHub Desktop.
SQL row to columns
select Parts.Id, Parts.Name, Parts.CreatedTimestamp,
MAX(CASE WHEN Key = "TEST" THEN Value END) test_key,
MAX(CASE WHEN Key = "ANOTHER" THEN Value END) another_key
from parts
left outer join Properties P on Parts.Id = P.PartId
group by Parts.Id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment