Hi
I have an table containing hourly values and I want to write a query to extract a couple of columns based on the maximum value of one of the extracted columns. The query I wrote is:
The above gives one row in the form:
This query doesn't look very efficient to me. Moreover, I can only run the query for one day.
Is there a way I can get the above-mentioned for more than 1 day? I need to query/compute values based on the maximum value of COL1 out of 24 hourly values for each day.
Regards
Shajju
I have an table containing hourly values and I want to write a query to extract a couple of columns based on the maximum value of one of the extracted columns. The query I wrote is:
Code:
SELECT * FROM
(SELECT DATETIME,NODE,COL1 AA, ((COL2+COL3)/COL1) BB
FROM
TABLE
WHERE DATETIME BETWEEN TRUNC(SYSDATE)-3 and TRUNC(SYSDATE)-2-1/86400 AND NODE='ABC')
WHERE COL1 in
(SELECT MAX(COL1)
FROM
(SELECT DATETIME, COL1
FROM TABLE
WHERE DATETIME BETWEEN TRUNC(SYSDATE)-3 and TRUNC(SYSDATE)-2-1/86400 AND NODE='ABC'))
Code:
DATETIME NODE AA BB
Is there a way I can get the above-mentioned for more than 1 day? I need to query/compute values based on the maximum value of COL1 out of 24 hourly values for each day.
Regards
Shajju