Search code examples
google-sheetsfiltergoogle-sheets-formulagoogle-query-language

How to pull one row data with query formula which has multiple row


I'm trying to pull data using query formula but the data has more than one row. here is the example of the data :

[here]:(https://i.sstatic.net/wmJop.png )

as you can see there is year column, i want to pull the data only one row which has the latest year. so i try to use "order by" formula. but it still didnt work. here is my formula :

=QUERY(Education!A$3:H$481, "SELECT Col4, Col5, Col6, Col7, Col8 WHERE Col1 ='"&A2&"' order by Col5 asc",0)

but it just return "#REF" just like this here

Could anyone help me to make the correct query formula which can pull one row with the latest year thank you


Solution

  • The error is saying that the array returned by the formula does not have enough room to expand. You have to clear the cells close to it or move so it can expand.

    If you only want to return the first row, you can use the limit clause.

    =QUERY(Education!A$3:H$481,
       "SELECT Col4, Col5, Col6, Col7, Col8
        WHERE Col1 ='"&A2&"'
        order by Col5 asc
        limit 1",0)