One of the tasks that cannot be solved using standard Google Sheets tools but can be handled with an SQL query is mass updating data with conditions. For example:
Task: Increase the Annual Salary
by 10% for all employees working in the “IT” department who have more than 5 years of tenure.
SQL query for this task:
UPDATE "Employees!A1:E5?headers=1" SET Salary = Salary * 1.10 WHERE Department = 'IT' AND strftime ('%Y', 'now') - strftime ('%Y', "Hire Date") > 5;
Why this is challenging to implement using standard Google Sheets tools:
- Mass updates: In Google Sheets, you would need to manually calculate tenure, filter data, add helper columns, and then recalculate salaries.
- Conditional updates: Formulas in Google Sheets work on individual cells or ranges but cannot apply mass updates based on conditions (e.g., tenure and department).
- Automation: Applying such changes requires manual copying and pasting of data into the original table, increasing the risk of errors.
SQL enables you to execute all these actions in a single query, ensuring precision and automation.
Using SQL in Google Sheets
With the SheetQuery add-on, you can run SQL queries directly in Google Sheets:
- Install SheetQuery from the Google Workspace Marketplace.
- Get a sample dataset
- Run the query above.