Google Sheets Query Language – A Comprehensive Guide

google sheetsgoogle-sheets-query

My goal is to select (count a number of rows with data) based on a condition. My query looks so basic but it does not work.

=query(A:B,"select count(B) where (A = '44')",)

My result is "count" as you can see on enclosed link.

https://docs.google.com/spreadsheets/d/1JDY5AsKDrK-LNBHDN5JLwVuqhNgwga95a9V6w-ODKpo/edit#gid=0

Best Answer

Formula

=query(A:B,"select count(B) where (A = 44)",)

Explanation

As the values on column A are numbers, QUERY set the column data type as number. Enclosing a number between single quotes/apostrophes makes it to be a string, so comparing a string to a number returns FALSE.

To remove the header try

=query(A:B,"select count(B) where (A = 44) label count(B) ''",)