1

I have the following data in a Google Spreadsheet:

1   shiplu  rice
2   sharmin rice
3   sharmin fast food
4   sharmin salad
5   rafiq   burger
6   nazia   noodles
7   rafiq   salad
8   rafiq   noodles
9   nazia   rice
10  razib   rice

The first column is in fact a timestamp, but I used integer to make it more readable. The other columns are username and food item.

I need to get the last food inputed by an user. The output should looke like this:

1   shiplu  rice
4   sharmin salad
8   rafiq   noodles
9   nazia   rice
10  razib   rice

I used the following query, but it does not give the desired output:

=QUERY(A1:C10;"select B, C group by B order by A")

How can I achieve this?

This is the spreadsheet in question.

1

At the moment I can't see how to achieve what you want solely with a QUERY, but:

=QUERY(A1:C, "Select MAX(A), B GROUP BY B ORDER BY MAX(A)")  

will return the left-hand and middle columns, ordered as required, and the right-hand column might be completed with say a lookup such as:

=VLOOKUP(H3,A:C,3,0)  

copied down to suit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.