Last active
April 17, 2019 13:21
-
-
Save Brutt/fe7c4daab83338dbb3d9a71d3613fe85 to your computer and use it in GitHub Desktop.
Unpivot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH calendar as ( | |
SELECT 1 as shop_id, 0 as mon, 0 as tue, 1 as wed, 1 as thur, 1 as fri, 0 as sat, 0 as sun FROM dual | |
UNION ALL | |
SELECT 2 as shop_id, 1 as mon, 1 as tue, 1 as wed, 1 as thur, 0 as fri, 0 as sat, 0 as sun FROM dual | |
) | |
SELECT shop_id, dayOfWeek, isWorkDay | |
FROM calendar | |
UNPIVOT ( | |
isWorkDay | |
FOR dayOfWeek IN (mon, tue, wed, thur, fri, sat, sun) | |
) | |
WHERE shop_id = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment