Search code examples
google-sheetsgoogle-query-language

Google Sheets QUERY most recent unique entries


I am trying to use the QUERY function on a list of Google Form responses to only display the most recent of unique entries(based on the key Student ID).

A = Timestamp Column 
C = Student ID Column

Using:

select max(A)
group by C

I was able to get the right entries, but only one column for each(I want all the data, the whole row, from the right entries)

So I tried using:

select max(A),B,C,D,E,F,G,H 
group by C

But this gives an error

Unable to parse query string for Function QUERY parameter 2: ADD_COL_TO_GROUP_BY_OR_AGGB

I am new to databases, first time using QUERY. Sorry if this is confusing, but maybe the sheet makes more sense: spreadsheet


Solution

  • In addition to Chris' contribution and using QUERY():

    =ArrayFormula(vlookup(query({row(Raw!A:A),sort(Raw!A:J)},
    "select max(Col1) where Col4 is not null group by Col4 label max(Col1)''",0),
    {row(Raw!A:A),sort(Raw!A:J)},{2,3,4,5,6,7,8,9,10,11},1))