Find Top 1000 entries along with count and rank from table
Clash Royale CLAN TAG #URR8PPP Find Top 1000 entries along with count and rank from table I have a table with around 30 billions rows in Redshift with following structure, userid itemid country start_date uid1 itemid1 country1 2018-07-25 00:00:00 uid2 itemid2 country1 2018-07-25 00:00:00 uid3 itemid1 country2 2018-07-25 00:00:00 uid4 itemid3 country1 2018-07-25 00:00:00 uid5 itemid1 country1 2018-07-25 00:00:00 uid1 itemid2 country2 2018-07-25 00:00:00 uid2 itemid2 country2 2018-07-25 00:00:00 Here, I want to find item's are bought by how many unique users and then pick top 1000 most sold item for each country and start_date. Here, both rank and number of times item sold is required. Following output is expected itemid country sold_count start_date itemid1 country1 2 2018-07-25 00:00:00 itemid2 country2 2 2018-07-25 00:00:00 itemid1 country2 1 2018-07-25 00:00:00 itemid2 country...