How to use Query function in Google Spreadsheet

This tutorial is about the Query function that is available in Google Spreadsheet. Query function allows users to perform a query over an array of values and is based on the Google Visualization API Query Language.

Let us try to understand the usage with a simple example that we had used for explaining Filter function in Google Spreadsheet. The objective is to retrieve the values from Result which is greater than 22500 and Type is greater than 6

The Query for retrieving the required result is

=QUERY(B1:C21,”select B where B > 22500 and C > 6″)

Where B1:C21 is the data source for the query and B > 22500 and C > 6 are the two conditions. The query gets you the expected result as shown below.

In Category: Blogging

Ravi Shankar

A Software developer and blogger who is always looking to provide technical help to the wider community.

Show 3 Comments
  • ulisse September 14, 2012, 8:11 pm

    hi,
    i have a problem.
    Query fucntion goes on the same sheet, but if I wont use another sheet as referement into query function how can i do?

    example:
    =query(A1:L28;”select C where C= ‘ulisse'”) is ok
    but
    =query(Sheet1!1:28;”select Sheet1!A:A where Sheet2!A4= ‘ulisse'”)
    don’t go.

  • ulisse September 14, 2012, 8:11 pm

    hi,
    i have a problem.
    Query fucntion goes on the same sheet, but if I wont use another sheet as referement into query function how can i do?

    example:
    =query(A1:L28;”select C where C= ‘ulisse'”) is ok
    but
    =query(Sheet1!1:28;”select Sheet1!A:A where Sheet2!A4= ‘ulisse'”)
    don’t go.

  • filipe July 19, 2013, 6:02 pm

    ulisse, did you find and answer for your problem?

Leave a Comment

Get your free copies of the following tech guides by joining the Digital Answers mailing list.