Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Select Unique on 1 Column in Google Sheets - Distinct Doesn't

$
0
0

I'm trying to set up a kind of a bid thing, where the top 5 respondents receive a prize. I was hoping to use SQL to get the top 5, but I can't remove duplicate bidders and only take their top bid. I wanted to do something like this:

=QUERY(range, "SELECT timestamp, bid, DISTINCT name, department ORDER BY bid DESC LIMIT 5")

But DISTINCT doesn't work in Google Sheets. Any idea as to what I should do in this situation?

Here is my dummy data set (ignore the timestamps):

TimestampBid ($)NameDepartment
2/16/2021 10:45:0718JimAccounting
2/16/2021 9:42:4022BobAccounting
2/16/2021 9:26:1521SamanthaSales
2/16/2021 9:26:1530JimAccounting
2/16/2021 10:45:0743JimAccounting
2/16/2021 9:42:4023SusanEngineering
2/16/2021 9:26:1545SusanEngineering
2/16/2021 9:26:1526AlexHR
2/16/2021 10:45:0712GeoffSales
2/16/2021 9:42:4012SarahSales

This is my desired outcome:

TimestampBid ($)NameDepartment
2/16/2021 9:26:1545SusanEngineering
2/16/2021 10:45:0743JimAccounting
2/16/2021 9:26:1526AlexHR
2/16/2021 9:42:4022BobAccounting
2/16/2021 9:26:1521SamanthaSales

This is what I have so far. You can see that Jim and Susan are in the table twice and that Bob and Samantha have missed out on placing as a result of this.Using the query:

=QUERY(A3:D12, "SELECT A, B, C, D ORDER BY B DESC LIMIT 5")
TimestampBid ($)NameDepartment
2/16/2021 9:26:1545SusanEngineering
2/16/2021 10:45:0743JimAccounting
2/16/2021 9:26:1530JimAccounting
2/16/2021 9:26:1526AlexHR
2/16/2021 9:42:4023SusanEngineering

Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>