The new forums will be named Coin Return (based on the most recent
vote)! You can check on the status and timeline of the transition to the new forums
here.
The Guiding Principles and New Rules
document is now in effect.
Tricky SQL without subqueries
I've got a working solution for this, but in the interest of performance I want to see if it can be done in a single query. Given the following table:
a | 1
a | 6
a | 2
b | 3
b | 5
I'm trying to get only those rows which have the greatest number for a given letter. So, this:
a | 6
b | 5
I could have sworn there was a way to do this with group by/having. Any ideas?
0
Posts
Something like:
If you've got other fields in the data that you want to pick up then it gets a bit trickier! Are the values in the 2nd column always unique?
This is already the result of 3 joins, and I don't know if I'm just tired or what but my brain is breaking even trying to figure out how to do it with subqueries.
Also, what database system are you using are you using?
Doc: That's right, twenty five years into the future. I've always dreamed on seeing the future, looking beyond my years, seeing the progress of mankind. I'll also be able to see who wins the next twenty-five world series.
I actually want to ask an sql question; should I do it here or in Moe's?
Doc: That's right, twenty five years into the future. I've always dreamed on seeing the future, looking beyond my years, seeing the progress of mankind. I'll also be able to see who wins the next twenty-five world series.