3

The following formula produces a 2-row result for me: a header row and a data row

=QUERY(A1:I7,"select B,C where A=1",-1)

I would like to have a single-row result: just data, without header.

I found similar questions, but none of the answers are applicable to my question, because I do not use SUM() or other aggregate functions.

Google SpreadSheet Query: Can I remove column header? https://productforums.google.com/forum/#!topic/docs/0CPyUKPSl5E https://productforums.google.com/forum/#!topic/docs/UEYtMBH_Wnk

Community
  • 1
  • 1
Andrej Adamenko
  • 1,650
  • 15
  • 31

2 Answers2

5

I found an answer here:

=QUERY(A1:I7,"select B,C where A=1 label B '',C ''",-1)
Andrej Adamenko
  • 1,650
  • 15
  • 31
  • This worked for me, thanks! FYI, Setting the header to 0 or -1 does not work if you're using a function like count(). So in my case I was counting column B where A equals 1. This got a single result with no header: `=query($A2:$C,"select count(B) where A=1 label count(B) ''")` – mattador Dec 02 '21 at 18:47
0

Instead of labeling column names as blanks using '', you can omit all headers like this:

=QUERY('Все'!A1:I7,"select B,C where A=1", 0)

By removing headers from the input, you drop the headers from the output.

patrickgamer
  • 511
  • 3
  • 15
Steven M. Mortimer
  • 1,618
  • 14
  • 36
  • 4
    I'm confused why this is the accepted answer. The question asks "how to remove header from the output" and this answers "how to remove header from input". – 7yl4r Oct 05 '17 at 18:09
  • 4
    Removing the headers from the input automatically removes them from the output without the need to individually provide blank labels. It might not be syntactically correct, but it works and is more concise. – Steven M. Mortimer Oct 15 '17 at 13:32
  • 1
    Ah, I see. When using `select` this is true. In my case I was testing with a `pivot` query which generates headers not included in the input, and ended up needing to use `query(query(...), "select * offset 1")` https://stackoverflow.com/a/38263548/1483986 – 7yl4r Oct 16 '17 at 14:49