Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- 'nbr_hr' AS field_name,
- TO_CHAR(MAX(CASE WHEN day_id = 1 THEN nbr_hr END)) AS monday,
- TO_CHAR(MAX(CASE WHEN day_id = 2 THEN nbr_hr END)) AS tuesday,
- TO_CHAR(MAX(CASE WHEN day_id = 3 THEN nbr_hr END)) AS wednesday,
- TO_CHAR(MAX(CASE WHEN day_id = 4 THEN nbr_hr END)) AS thursday,
- TO_CHAR(MAX(CASE WHEN day_id = 5 THEN nbr_hr END)) AS friday,
- TO_CHAR(MAX(CASE WHEN day_id = 6 THEN nbr_hr END)) AS saturday,
- TO_CHAR(MAX(CASE WHEN day_id = 7 THEN nbr_hr END)) AS sunday
- FROM working_schedule_day
- WHERE working_schedule_id = :working_schedule_id
- UNION ALL
- SELECT
- 'nbr_hr_am' AS field_name,
- TO_CHAR(MAX(CASE WHEN day_id = 1 THEN nbr_hr_am END)) AS monday,
- TO_CHAR(MAX(CASE WHEN day_id = 2 THEN nbr_hr_am END)) AS tuesday,
- TO_CHAR(MAX(CASE WHEN day_id = 3 THEN nbr_hr_am END)) AS wednesday,
- TO_CHAR(MAX(CASE WHEN day_id = 4 THEN nbr_hr_am END)) AS thursday,
- TO_CHAR(MAX(CASE WHEN day_id = 5 THEN nbr_hr_am END)) AS friday,
- TO_CHAR(MAX(CASE WHEN day_id = 6 THEN nbr_hr_am END)) AS saturday,
- TO_CHAR(MAX(CASE WHEN day_id = 7 THEN nbr_hr_am END)) AS sunday
- FROM working_schedule_day
- WHERE working_schedule_id = :working_schedule_id
- UNION ALL
- SELECT
- 'nbr_hr_am' AS field_name,
- TO_CHAR(MAX(CASE WHEN day_id = 1 THEN nbr_hr_am END)) AS monday,
- TO_CHAR(MAX(CASE WHEN day_id = 2 THEN nbr_hr_am END)) AS tuesday,
- TO_CHAR(MAX(CASE WHEN day_id = 3 THEN nbr_hr_am END)) AS wednesday,
- TO_CHAR(MAX(CASE WHEN day_id = 4 THEN nbr_hr_am END)) AS thursday,
- TO_CHAR(MAX(CASE WHEN day_id = 5 THEN nbr_hr_am END)) AS friday,
- TO_CHAR(MAX(CASE WHEN day_id = 6 THEN nbr_hr_am END)) AS saturday,
- TO_CHAR(MAX(CASE WHEN day_id = 7 THEN nbr_hr_am END)) AS sunday
- FROM working_schedule_day
- WHERE working_schedule_id = :working_schedule_id
- UNION ALL
- SELECT
- 'nbr_hr_for_absence' AS field_name,
- TO_CHAR(MAX(CASE WHEN day_id = 1 THEN nbr_hr_for_absence END)) AS monday,
- TO_CHAR(MAX(CASE WHEN day_id = 2 THEN nbr_hr_for_absence END)) AS tuesday,
- TO_CHAR(MAX(CASE WHEN day_id = 3 THEN nbr_hr_for_absence END)) AS wednesday,
- TO_CHAR(MAX(CASE WHEN day_id = 4 THEN nbr_hr_for_absence END)) AS thursday,
- TO_CHAR(MAX(CASE WHEN day_id = 5 THEN nbr_hr_for_absence END)) AS friday,
- TO_CHAR(MAX(CASE WHEN day_id = 6 THEN nbr_hr_for_absence END)) AS saturday,
- TO_CHAR(MAX(CASE WHEN day_id = 7 THEN nbr_hr_for_absence END)) AS sunday
- FROM working_schedule_day
- WHERE working_schedule_id = :working_schedule_id
- UNION ALL
- SELECT
- 'ph_mobility' AS field_name,
- TO_CHAR(MAX(CASE WHEN day_id = 1 THEN ph_mobility END)) AS monday,
- TO_CHAR(MAX(CASE WHEN day_id = 2 THEN ph_mobility END)) AS tuesday,
- TO_CHAR(MAX(CASE WHEN day_id = 3 THEN ph_mobility END)) AS wednesday,
- TO_CHAR(MAX(CASE WHEN day_id = 4 THEN ph_mobility END)) AS thursday,
- TO_CHAR(MAX(CASE WHEN day_id = 5 THEN ph_mobility END)) AS friday,
- TO_CHAR(MAX(CASE WHEN day_id = 6 THEN ph_mobility END)) AS saturday,
- TO_CHAR(MAX(CASE WHEN day_id = 7 THEN ph_mobility END)) AS sunday
- FROM working_schedule_day
- WHERE working_schedule_id = :working_schedule_id
- UNION ALL
- SELECT
- 'hp_mobility' AS field_name,
- TO_CHAR(MAX(CASE WHEN day_id = 1 THEN hp_mobility END)) AS monday,
- TO_CHAR(MAX(CASE WHEN day_id = 2 THEN hp_mobility END)) AS tuesday,
- TO_CHAR(MAX(CASE WHEN day_id = 3 THEN hp_mobility END)) AS wednesday,
- TO_CHAR(MAX(CASE WHEN day_id = 4 THEN hp_mobility END)) AS thursday,
- TO_CHAR(MAX(CASE WHEN day_id = 5 THEN hp_mobility END)) AS friday,
- TO_CHAR(MAX(CASE WHEN day_id = 6 THEN hp_mobility END)) AS saturday,
- TO_CHAR(MAX(CASE WHEN day_id = 7 THEN hp_mobility END)) AS sunday
- FROM working_schedule_day
- WHERE working_schedule_id = :working_schedule_id
- UNION ALL
- SELECT
- 'start_working_time' AS field_name,
- TO_CHAR(MAX(CASE WHEN day_id = 1 THEN start_working_time END), 'HH24:MI') AS monday,
- TO_CHAR(MAX(CASE WHEN day_id = 2 THEN start_working_time END), 'HH24:MI') AS tuesday,
- TO_CHAR(MAX(CASE WHEN day_id = 3 THEN start_working_time END), 'HH24:MI') AS wednesday,
- TO_CHAR(MAX(CASE WHEN day_id = 4 THEN start_working_time END), 'HH24:MI') AS thursday,
- TO_CHAR(MAX(CASE WHEN day_id = 5 THEN start_working_time END), 'HH24:MI') AS friday,
- TO_CHAR(MAX(CASE WHEN day_id = 6 THEN start_working_time END), 'HH24:MI') AS saturday,
- TO_CHAR(MAX(CASE WHEN day_id = 7 THEN start_working_time END), 'HH24:MI') AS sunday
- FROM working_schedule_day
- WHERE working_schedule_id = :working_schedule_id
- UNION ALL
- SELECT
- 'stop_working_time' AS field_name,
- TO_CHAR(MAX(CASE WHEN day_id = 1 THEN stop_working_time END), 'HH24:MI') AS monday,
- TO_CHAR(MAX(CASE WHEN day_id = 2 THEN stop_working_time END), 'HH24:MI') AS tuesday,
- TO_CHAR(MAX(CASE WHEN day_id = 3 THEN stop_working_time END), 'HH24:MI') AS wednesday,
- TO_CHAR(MAX(CASE WHEN day_id = 4 THEN stop_working_time END), 'HH24:MI') AS thursday,
- TO_CHAR(MAX(CASE WHEN day_id = 5 THEN stop_working_time END), 'HH24:MI') AS friday,
- TO_CHAR(MAX(CASE WHEN day_id = 6 THEN stop_working_time END), 'HH24:MI') AS saturday,
- TO_CHAR(MAX(CASE WHEN day_id = 7 THEN stop_working_time END), 'HH24:MI') AS sunday
- FROM working_schedule_day
- WHERE working_schedule_id = :working_schedule_id
- UNION ALL
- SELECT
- 'pause_start_time' AS field_name,
- TO_CHAR(MAX(CASE WHEN day_id = 1 THEN pause_start_time END), 'HH24:MI') AS monday,
- TO_CHAR(MAX(CASE WHEN day_id = 2 THEN pause_start_time END), 'HH24:MI') AS tuesday,
- TO_CHAR(MAX(CASE WHEN day_id = 3 THEN pause_start_time END), 'HH24:MI') AS wednesday,
- TO_CHAR(MAX(CASE WHEN day_id = 4 THEN pause_start_time END), 'HH24:MI') AS thursday,
- TO_CHAR(MAX(CASE WHEN day_id = 5 THEN pause_start_time END), 'HH24:MI') AS friday,
- TO_CHAR(MAX(CASE WHEN day_id = 6 THEN pause_start_time END), 'HH24:MI') AS saturday,
- TO_CHAR(MAX(CASE WHEN day_id = 7 THEN pause_start_time END), 'HH24:MI') AS sunday
- FROM working_schedule_day
- WHERE working_schedule_id = :working_schedule_id
- UNION ALL
- SELECT
- 'pause_stop_time' AS field_name,
- TO_CHAR(MAX(CASE WHEN day_id = 1 THEN pause_stop_time END), 'HH24:MI') AS monday,
- TO_CHAR(MAX(CASE WHEN day_id = 2 THEN pause_stop_time END), 'HH24:MI') AS tuesday,
- TO_CHAR(MAX(CASE WHEN day_id = 3 THEN pause_stop_time END), 'HH24:MI') AS wednesday,
- TO_CHAR(MAX(CASE WHEN day_id = 4 THEN pause_stop_time END), 'HH24:MI') AS thursday,
- TO_CHAR(MAX(CASE WHEN day_id = 5 THEN pause_stop_time END), 'HH24:MI') AS friday,
- TO_CHAR(MAX(CASE WHEN day_id = 6 THEN pause_stop_time END), 'HH24:MI') AS saturday,
- TO_CHAR(MAX(CASE WHEN day_id = 7 THEN pause_stop_time END), 'HH24:MI') AS sunday
- FROM working_schedule_day
- WHERE working_schedule_id = :working_schedule_id
- UNION ALL
- SELECT
- 'working_schedule_id' AS field_name,
- TO_CHAR(MAX(CASE WHEN day_id = 1 THEN working_schedule_id END)) AS monday,
- TO_CHAR(MAX(CASE WHEN day_id = 2 THEN working_schedule_id END)) AS tuesday,
- TO_CHAR(MAX(CASE WHEN day_id = 3 THEN working_schedule_id END)) AS wednesday,
- TO_CHAR(MAX(CASE WHEN day_id = 4 THEN working_schedule_id END)) AS thursday,
- TO_CHAR(MAX(CASE WHEN day_id = 5 THEN working_schedule_id END)) AS friday,
- TO_CHAR(MAX(CASE WHEN day_id = 6 THEN working_schedule_id END)) AS saturday,
- TO_CHAR(MAX(CASE WHEN day_id = 7 THEN working_schedule_id END)) AS sunday
- FROM working_schedule_day
- WHERE working_schedule_id = :working_schedule_id
- UNION ALL
- SELECT
- 'day_id' AS field_name,
- TO_CHAR(MAX(CASE WHEN day_id = 1 THEN day_id END)) AS monday,
- TO_CHAR(MAX(CASE WHEN day_id = 2 THEN day_id END)) AS tuesday,
- TO_CHAR(MAX(CASE WHEN day_id = 3 THEN day_id END)) AS wednesday,
- TO_CHAR(MAX(CASE WHEN day_id = 4 THEN day_id END)) AS thursday,
- TO_CHAR(MAX(CASE WHEN day_id = 5 THEN day_id END)) AS friday,
- TO_CHAR(MAX(CASE WHEN day_id = 6 THEN day_id END)) AS saturday,
- TO_CHAR(MAX(CASE WHEN day_id = 7 THEN day_id END)) AS sunday
- FROM working_schedule_day
- WHERE working_schedule_id = :working_schedule_id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement