If you think that you could ORDER by *bar* and then GROUP *foo*, you can't, as GROUP is run first, making your ORDER pointless.
If you think that you could use MAX(*bar*) and then GROUP by *foo*, you can't, as the *uid* will be bogus (and all other data in the column). You want the row with the highest *bar*, not just the highest *bar* shoved into the first (wrong) row!
I'm really stuck. Any ideas will be greatly appreciated!!!
Ah, this isn't my homework, that's really offensive, mate. I am doing this for my own personal website listing frame designs that have a year, and I need the latest year only (listing other years below), if that makes sense.
Thanks for your help, though. But please... go abuse someone else, that actually deserves it, perhaps.
Assuming I understand your post correctly, you are suggesting to finding the single highest *bar* value and returning all rows with that value. With the above data (with 880 and 200 being the highest in the grouped *foos*), only one row would be returned... whereas I want the following results:
this isn't my homework, that's really offensive, mate
It's not abuse, it's simply suspicion that I'm wasting my own time doing other peoples homework. Many of the posts at the moment are from kids just posting their homework on the forum and expecting us to do it. their queries are usually on trivial data sets with nonsensical field names (foo, bar etc). Usually their posts are the first (and often only) post they've ever made (yours is post 1). Hence I'm suspicious
Is there a way? Any help much appreciated. I've spent days on this issue now getting nowhere, and I'm only now asking for help.
My first response did show how to solve the problem but seeing as you're not a student then the full answer would be :
select * from MyTab
where bar = ( select max(bar) from MyTab )
When all the field names are completely meaningless it's difficult to work out whether you've answered the query correctly or not - it certainly looked like what he was after but then I was typing as quickly as possible hoping to get my response out before you had time to get in a sarcastic remark - sadly I failed