Timeline for SQL - How to select a row having a column with max value
Current License: CC BY-SA 2.5
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 19, 2010 at 0:32 | comment | added | Jeffrey Kemp | Yeah. Sujee beat me to the ROWNUM solution which is better :) | |
| May 18, 2010 at 8:15 | comment | added | Rob van Wijk | It avoids scanning the table twice, but it calculates the first_value column for every row, and then the distinct discards them all but one. Better than most other answers, but aggregating is the way to go here. | |
| May 18, 2010 at 5:41 | comment | added | Jeffrey Kemp | If you have an index on (value_col, date_col) you'll find that Oracle will do quite well using Sujee's query, since it will use the COUNT STOPKEY optimization. | |
| May 18, 2010 at 4:22 | comment | added | TerrorAustralis | I would be interested in seeing what kind of performance difference this had, from a purely educational point of view. From Toms asktom.oracle site i had understood there were significant overheads in using FIRST_VALUE. Is it possible that you could direct me to some performance results comparing them? | |
| May 18, 2010 at 4:04 | history | answered | Jeffrey Kemp | CC BY-SA 2.5 |