Select a row having a column with max value - On a date range
- by Abhi
Excuse me for posting a similar question. Please consider this:
date                 value
18/5/2010, 1 pm        40
18/5/2010, 2 pm        20
18/5/2010, 3 pm        60
18/5/2010, 4 pm        30
18/5/2010, 5 pm        60
18/5/2010, 6 pm        25 
19/5/2010, 6 pm        300 
19/5/2010, 6 pm        450 
19/5/2010, 6 pm        375 
20/5/2010, 6 pm        250 
20/5/2010, 6 pm        310 
The query is to get the date and value for each day such that the value obtained for that day is max. If the max value is repeated on that day, the lowest time stamp is selected. The result should be like:
18/5/2010, 3 pm        60
19/5/2010, 6 pm        450
20/5/2010, 6 pm        310
The query should take in a date range like the one given below and find results for that range in the above fashion:
where
    date = to_date('26/03/2010','DD/MM/YYYY') AND
    date < to_date('27/03/2010','DD/MM/YYYY')