Lets say I have this table:
PetID Name Age Weight
How can I in a Linq2SQL get the name, age and weight of each pet that is the heaviest in its age group?
So if I have one pet of age 5 and four pets of age 2, I would like the Name, Age and Weight of the one that is age 5, and the one of the four with age 2 that is the heaveiest of those four.
This should probably not be too difficult, but I am not too into query thinking yet. Working on it though. And this is one kind of problem that I will need many times, but doesn't quite manage to wrap my head around how to do...
I think it would include using the Max or a > operator, and some sort of grouping or joining, but thats about as far as I've gotten....
Thanks for the answers. All of them put me on the right track when it comes to the GroupBy stuff. The one I marked as an answer, was the one that was closest to what I ended up with.