In this article:

SQL on Google Sheets? How?

December 5, 2024
>Click here to Import a MYSQL Database to a Lido Spreadsheet

How Google Query Language works


The Google Query Language (Google QL) is Google’s own implementation of SQL. It can be used as a command inside the QUERY function. The QUERY function has the following syntax:


QUERY(data, query, [headers])


In this function, data is the range of cells where the query command will be performed, query is the query we will send to be processed, enclosed in double quotation marks, and [headers] is an optional command to identify how many header rows are in the sheet. 


Basically, the QUERY function is created so that you can use the Google QL, which is Google’s own form of SQL, on the data stored in the sheets. Therefore, Google QL can only read the data in the database, but it cannot  modify the data.


Taking note of how the Google QL works, the following sections will focus on the SQL commands present as well as those that do not explicitly exist but can be replicated. 

SQL commands not present in Google Sheets 


As stated in the previous section, the Google QL can read the data in the database but not modify the data stored in the database. Therefore, the following SQL commands have no equivalent in Google Sheets:


  • Insert Into
  • Insert Into Select
  • Update
  • Delete


SQL commands present in Google Sheets


The following commands are present in Google Sheets, though might come with a different command name:


SQL: Select, Select Into 

Google QL: SELECT works like SELECT INTO. Data & Analytics How to Select Multiple Columns through SQL Query in Google Sheets 


SQL: Where

Google QL: WHERE. How to Use Basic SQL Commands + Query Another Sheet in Google Sheets 


SQL: And, Or, Not

Google QL: AND, OR, NOT. Data & Analytics How to Use SQL Query with Multiple Criteria in Google Sheets


SQL: Order By

Google QL: ORDER BY. How to Use Basic SQL Commands + Query Another Sheet in Google Sheets


SQL: Group By

Google QL: GROUP BY. Data & Analytics How to Use the 'Group by' SQL Clause in Google Sheets 


SQL: Select Top/Limit/Fetch First

Google QL: LIMIT. How to Use the SQL Limit and Offset Clause in Google Sheets 


SQL: Min, Max

Google QL: MIN, MAX. How to Use SQL Query for Aggregate Values in Google Sheets 


SQL: Count, Avg, Sum

Google QL: COUNT, AVG, SUM. How to Use SQL Query for Aggregate Values in Google Sheets 


SQL: Like (and the wildcards used in searching for strings in SQL)

Google QL: LIKE. How to Use SQL Queries to Search for Specific Words in Google Sheets 


SQL: As

Google QL: LABEL. How to Use SQL Labels in Google Sheets


SQL: Date, Datetime

Google QL: DATE, DATETIME. Working with Date and Time in SQL in Google Sheets 


SQL commands with equivalent separate function in Google Sheets


The following SQL commands are not present as a Google QL command but can be implemented either as a function or through other syntax:


SQL: Select Distinct

Google QL: UNIQUE function. 


SQL: Between

Google QL: As the command checks for the entries that have a value between an upper and lower limit, a similar construction can work. For an example, we want to list entries whose values in column C are between 10 and 20:


select * where C>10 and C<20


SQL: Join

Google QL: A combination of VLOOKUP and other functions can mimic the Join command in SQL. Click here for our tutorial

Google QL commands not present in SQL



There are commands present in Google QL that are either not present in SQL or serve as a specialized command for representing certain syntax in SQL:


PIVOT sorts the unique values in a column to its own individual columns and summarizes them, similar to a Google Sheets Pivot Table. Learn more here: Data & Analytics How to Use the SQL Pivot Clause in Google Sheets


FORMAT modifies how the data is displayed when copied to the destination sheet. Learn more here:  How to Use SQL Queries to Format Google Sheets


STARTS WITH lets you search for rows where its value in a specific column starts with the given string, but the total value of the cell could be longer than the given string. ENDS WITH is a similar command but is used when you know the last few characters of a string. MATCHES and CONTAINS are shorthand ways to filter rows where its value in a specific column equals a given string or contains the given string. They are alternative ways of writing column_name=”value”. You can check the examples of these three commands here: How to Use Basic SQL Commands + Query Another Sheet in Google Sheets


OFFSET lets you skip the first few entries, copying first the entries somewhere on the middle of the sheet. You can check the examples here: How to Use the SQL Limit and Offset Clause in Google Sheets 



Get Google Sheets productivity and automation tips delivered straight to your inbox
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
We'll email you 1-3 times a week — and never share your information.

Work less, automate more!

Use Lido to connect your spreadsheets to email, Slack, calendars, and more to automate data transfers and eliminate manual copying and pasting. View all use cases ->