Using Oracle SQL.
COL1 COL2 COL3 COL4
2017-12-01 2017-12-01 02:00 296.82 161
2017-12-01 2017-12-01 06:00 287.25 158
2017-12-01 2017-12-01 10:00 290.3 157
2017-12-01 2017-12-01 14:00 345.58 157
2017-12-01 2017-12-01 18:00 285.13 156
2017-12-01 2017-12-01 22:00 287.68 158
2017-12-02 2017-12-02 02:00 306.5 164
2017-12-02 2017-12-02 06:00 315.79 166
2017-12-02 2017-12-02 10:00 307.59 164
What I need to do is get the MAX(COL3) from each day but I need the other values out of the row as well....I can group by COL1 but I'm having issues returning the other values COL2 and COL4 from the row as well.
Almost there however this is not working It is saying that the from is in a bad location.....
SELECT *,MAX(VDC) OVER (PARTITION BY DATETHE) from (select
trunc(x.lvl) "DATETHE",
energy_metrics_pdu.WATTS_READING "PDU",
case energy_metrics_pdu.watts_reading
when 0 then NULL
else round(energy_metrics_vdc.watts_reading/energy_metrics_pdu.WATTS_READING,2)
END "RATIO",
energy_metrics_vdc.watts_reading "VDC"
from ( SELECT to_date('01-DEC-2017','DD-MON-YYYY') + (level/24)-0 lvl
FROM dual
CONNECT BY LEVEL <= (5*24)-1 ) x
LEFT JOIN energy_metrics_pdu on to_char(x.lvl, 'YYYY-MM-DD HH24') = to_char(energy_metrics_pdu.READING_DATE, 'YYYY-MM-DD HH24')
LEFT join energy_metrics_vdc on to_char(x.lvl, 'YYYY-MM-DD HH24')||':00' = to_char(energy_metrics_vdc.READING_DATE, 'YYYY-MM-DD HH24:MI')
where energy_metrics_pdu.watts_reading IS NOT NULL order by "DATETHE" ASC
);
Any suggestions...