Skip to content

Instantly share code, notes, and snippets.

@Mikuana
Created October 17, 2016 20:15
Show Gist options
  • Save Mikuana/7f50d52eb5719beb9e702c41c5ec653b to your computer and use it in GitHub Desktop.
Save Mikuana/7f50d52eb5719beb9e702c41c5ec653b to your computer and use it in GitHub Desktop.
SELECT
dept_id AS dept_id
, 1 AS hours_id
, hours1 AS hours
FROM
hours_table t
WHERE
hours1 IS NOT NULL
UNION ALL
SELECT
dept_id AS dept_id
, 2 AS hours_id
, hours2 AS hours
FROM
hours_table t
WHERE
hours2 IS NOT NULL
/* ... repeat a whole bunch */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment