I am working with Microsoft ACCESS:
I want to create a query, where only the TOP N Profits from another Query are selected. I am using the function "ROW_NUMBER()" which I have seen posted here and in other groups, but when I try to run my SQL, it tells me it is wrong.
Does any of you know, what should I do different?
Here is my SQL-code:
SELECT * from (
select [Abfrage 13_Rank].[Product 1],
[Abfrage 13_Rank].[Product 2],
[Abfrage 13_Rank].[Product 3],
[Abfrage 13_Rank].[Country],
[Abfrage 13_Rank].Profit,
[Abfrage 13_Rank].ProductsCountry,
ROW_NUMBER() OVER (PARTITION BY ProductsCountry ORDER BY Profit DESC) AS RankSelect
FROM [Abfrage 13_Rank])
Where RankSelected=[Abfrage 14_Selected].Selected;
Also: My TOP N Profit, is not the same for each of my groups: my N, is different from group to group, and to get the N I am referring to another query ([abfrage 14_Selected]), and that's why I have the last row "Where....."
Thank you very much