I have this two queries (from SAME table), and want to combine into one SINGLE query, how?
How can we use CASE WHEN THEN for such situation?
Query1:
SELECT t_inner.*, Floor(t_inner.ProductiveTime/ 3600) || 'hr:' || LPAD(Floor(Mod(t_inner.ProductiveTime,3600) / 60),2,0) || 'min:' AS Productive_Time, Floor(t_inner.OperatorDownTime/ 3600) || 'hr:' || LPAD(Floor(Mod(t_inner.OperatorDownTime,3600) / 60),2,0) || 'min:' AS OperatorDown_Time FROM (SELECT SYSTEMTYPE, sum(TIME_TEST + TIME_STEP) AS ProductiveTime, sum(TIME_IDLE) AS OperatorDownTime FROM PFODS.PPL_TESTSYSTEMS_UTILISATION WHERE (SYSTEMTYPE = '0005-072') AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY')) AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400) AND MONO != '9999999999' GROUP BY SYSTEMTYPE ) t_inner
Query 2:
SELECT t_inner.*, Floor(t_inner.MachineDownTime/ 3600) || 'hr ' || LPAD(Floor(Mod(t_inner.MachineDownTime,3600) / 60),2,0) || 'min' AS MachineDown_Time FROM (SELECT SYSTEMTYPE, sum(TIME_IDLE) AS MachineDownTime FROM PFODS.PPL_TESTSYSTEMS_UTILISATION WHERE (SYSTEMTYPE = '0005-072') AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY')) AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400) AND MONO = '9999999999' GROUP BY SYSTEMTYPE) t_inner
see http://postimg.org/image/koq87iyyz/ andhttp://postimg.org/image/fv3zxa38n