Skip to content
Advertisement

sql – query for all values in table with limit

I have an SQL query which I run in Amazon Athena:

where I order by B and take the first row only for the value 1000 for A. However I want to run this query for all values of A in T i.e for each A in T get the first row only and append to the results.

How do I do this?

Example of table data:

and the result I want to get is:

Advertisement

Answer

You can try to use ROW_NUMBER window function to make it.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement