group by - How can I select several rows with the Max column value which is grouped by another column? -
I want to get the movie, character_name and visits of 4 rows (*) with the maximum "Visits" value group
My Table (D) is like this:
Movie CharacterName Visit 1 Owen Lars 1 Obi-Van Kani 2 1 Luke Skywalker 3 * 2 Princess Leah 2 2 Luke Skywalker 3 * 2 R2- D2 3 * 3 Jabba The Hut 1 3 Han Solo 2 3 Luke Skywalker 4 *
The best coding I can think of
select * FROM D group D. Maximum (visits) by Mavi Hewing
But I can not find the correct lines> Can anyone tell me how should I modify it? Thanks a lot!
SELECT D. * Join D Inner (SELECT MOVIE, from MAX (movies) movies F. On D.O.O.E.E = F.Movie and D. Visits = F. Visits
Comments
Post a Comment