Query Language Reference (Version 0.7) | Charts | Google for Developers
QUERY function - Google Docs Editors Help
Google Sheets supports a QUERY function using which we can run queries on a range of data.
The Google Visualization API Query Language has a SQL-like syntax and exposes a variety of functions to work on the selected range.
For example,
The following query groups by date summing the values in column B. The query runs on the range A:B
=QUERY(A:B, "SELECT todate(A), SUM(B) GROUP BY todate(A)")