Search code examples
google-sheetsgoogle-sheets-formulagoogle-sheets-querygoogle-query-language

Google Sheets 'order by' messed up by headers


I'm simply wanting to query 5 columns of data from 'Raw Paste' sheet, and then reorder them.

=QUERY('Raw Paste'!A:E, "select A, B, C, D, E order by B asc")

The problem is it appears the headers are messing it up (0 results)... if I do !A2:E900 it works but the problem is if I try to select "max" range it goes back to 0 results, which makes that useless if it can't just select ALL the rows without having to adjust 900 to fit whatever the data is.


Solution

  • try:

    =QUERY('Raw Paste'!A:E, "select A,B,C,D,E order by B", 0)
    

    or if you have headers:

    =QUERY('Raw Paste'!A:E, "select A,B,C,D,E order by B", 1)
    

    if you still got first rows empty you will need to include where like:

    =QUERY('Raw Paste'!A:E, "select A,B,C,D,E where A is not null order by B", 1)