Home > Blockchain >  How to Query in google sheets, sort by a column and not include that column in the output
How to Query in google sheets, sort by a column and not include that column in the output

Time:07-23

I would like to query in google sheets and sort the query by a specific column in accending order, and have a secondary sort that is also in ascending order. I already know how to do this by

=QUERY(A:C,"select * where month(A) 1 = 1 order by A,B ",0)

Here i queried 3 columns month, unique ID, and name. I selected the data with the necessary month, and sorted it by month, followed by a secondary sort of unique ID. But this query outputs 3 columns. How would i change the formula so the output does not include the month column anymore.

enter image description here

CodePudding user response:

Your question is:

How would i change the formula so the output does not include the month column anymore.

Try wrapping your QUERY formula within another QUERY. Like:

=QUERY(QUERY(your_query_here),"select Col2, Col3")  

For your given example it would be:

=QUERY(QUERY(A1:C22,"select * where month(A) 1 = 1 order by A,B ",0),
         "select Col1, Col3")
  • Related