I find very similar questions to mine, but noone contains my problem.
I work with ms-Acces: I need to create a Rank query of my groups, selecting the TOP N Profits for each group.
THE PROBLEM is that this "N" is not the same for each group, but I need to select every time different Ns...
So the usual TOP N function does not work for me...and COUNT does not work either. How can I rank pro group the TOP N=1 or 2 or 3 etc. according to a selection pro group, made in a previous query ([Abfrage 14_Selected])?
Here one example that does not (clearly) work, but I don´t know how to solve my problem:
SELECT TOP N [Abfrage 13_Rank].[Product 1], [Abfrage 13_Rank].[Product 2], [Abfrage 13_Rank].[Product 3], [Abfrage 13_Rank].Country, [Abfrage 13_Rank].ProductsCountry, [Abfrage 13_Rank].Profit FROM [Abfrage 13_Rank] LEFT JOIN [Abfrage 14_Selected] ON ([Abfrage 13_Rank].Country = [Abfrage 14_Selected].Country) AND ([Abfrage 13_Rank].[Product 3] = [Abfrage 14_Selected].[Product 3]) AND ([Abfrage 13_Rank].[Product 2] = [Abfrage 14_Selected].[Product 2]) AND ([Abfrage 13_Rank].[Product 1] = [Abfrage 14_Selected].[Product 1]) WHERE N= [Abfrage 14_Selected].Selected;
Thanks everyone