Timeline for answer to Fetch the rows which have the Max value for a column for each distinct value of another column by wcw
Current License: CC BY-SA 3.0
Post Revisions
3 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 26, 2012 at 13:40 | comment | added | cartbeforehorse |
Also, be aware that the QUALIFY clause is specific to Teradata. In Oracle (at least) you have to nest your query and filter using a WHERE clause on the wrapping select statement (which probably hits performance a touch, I'd imagine).
|
|
| May 26, 2012 at 13:18 | comment | added | cartbeforehorse |
This is the best answer in my opinion. However, be careful with the rank() function in situations where there are ties. You could end up with more than one rank=1. Better to use row_number() if you really do want just one record returned.
|
|
| Oct 19, 2011 at 16:17 | history | answered | wcw | CC BY-SA 3.0 |