Skip to content
Advertisement

aws athena SQL query; get unique count of column2 for each unique column1

I am fairly new to SQL queries, and am working with querying an aws athena database.

My first query will return every unique brand given some parameters:

Returning a list like this:

And so on and so on for 553 rows. If I pick any of the brands, such as ‘Seraz’ and run this second query, it will return that distinct count of that brand’s ‘merch1’ column

Which returns:

Where _col0 is the distinct count of merch1 for seraz.

My question is how can I combine my queries, so that for every unique brand result from query1, it runs query2, and presents the unique merch1 count in the table like so:

Advertisement

Answer

use group by with brand column

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