DimitarVasilev Jun 19th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT COALESCE(to_char(ocal.default_opening_time,'hh24:mi:ss'), to_char(cw.opening_time, 'hh24:mi:ss')) "Opening time", COALESCE(to_char(ocal.default_closing_time,'hh24:mi:ss'), to_char(cw.closing_time, 'hh24:mi:ss'))"Closing time", wc.work_code_name, CASE cw.weekday_nr WHEN 0 THEN 'none'
  2.                 WHEN 1 THEN 'Monday'
  3.                 WHEN 2 THEN 'Tuersday'
  4.                 WHEN 3 THEN 'Wednesday'
  5.                 WHEN 4 THEN 'Thursday'
  6.                 WHEN 5 THEN 'Friday'
  7.                 WHEN 6 THEN 'Saturday'
  8.                 WHEN 7 THEN 'sunday'
  9. END AS weekday
  10. FROM cal_weekday cw, work_code wc, oc_calendar ocal, operation_center oc, vehicle_owner vo
  11. WHERE cw.oc_calendar_id=ocal.oc_calendar_id
  12. AND ocal.operation_center_id=oc.operation_center_id
  13. AND vo.vehicle_owner_id=wc.vehicle_owner_id
  14. AND vo.vehicle_owner_id IN (SELECT vehicle_owner_id FROM vehicle_owner WHERE company_name LIKE '%COBELBA%')
  15. AND cw.is_open NOT LIKE 'N';
RAW Paste Data
Want to get better at SQL?
Learn to code SQL in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!