Update Snowflake Column Values Conditionally

Justin Aug 25, 2026

In the dynamic world of data management, Snowflake's ability to update column values based on specific conditions is a powerful feature that enhances data governance and accuracy. This article delves into the intricacies of this functionality, providing detailed steps and real-world examples to help you harness this capability.

Functions in Snowflake (2025): Complete Guide for Data Transformation & Analytics
Functions in Snowflake (2025): Complete Guide for Data Transformation & Analytics

Before we dive in, let's understand the basic syntax. In Snowflake, you can update column values based on a condition using the UPDATE statement. The syntax looks like this: UPDATE SET = WHERE ;

Conditional Formatting Entire Column Based on Another Column in Excel - ExcelDemy
Conditional Formatting Entire Column Based on Another Column in Excel - ExcelDemy

Understanding Column Updates

Before we explore conditional updates, let's ensure we understand the basic update operation.

Sum a Column Based on Values in Another - Excel University
Sum a Column Based on Values in Another - Excel University

For instance, let's say we have an EMPLOYEE table and we want to update the SALARY column for all employees where the DEPARTMENT is 'IT'. Here's how you'd do it:

```sql UPDATE EMPLOYEE SET SALARY = SALARY * 1.1 WHERE DEPARTMENT = 'IT'; ```

Updating with Literal Values

Star Schema vs Snowflake schema for Data Warehouse
Star Schema vs Snowflake schema for Data Warehouse

You can update a column to a literal value, as shown above. This is handy when you need to standardize data or correct errors.

For example, let's say we want to update the DEPARTMENT column for all employees where the COUNTRY is 'USA', setting it to 'North America':

```sql UPDATE EMPLOYEE SET DEPARTMENT = 'North America' WHERE COUNTRY = 'USA'; ```

Updating with Aggregate Functions

How to Transform Your Data in Snowflake - KDnuggets
How to Transform Your Data in Snowflake - KDnuggets

Snowflake also allows you to use aggregate functions in update statements. This can be useful in scenarios where you want to update a value based on the result of an aggregate function applied to another row.

Suppose we have a SALES table and we want to update the COMMISSION column to be 10% of the total sales for each employee. Here's how you'd do it:

```sql UPDATE SALES S SET COMMISSION = 0.1 * ( SELECT SUM(SALE_AMOUNT) FROM SALES WHERE EMPLOYEE_ID = S.EMPLOYEE_ID ); ```

Updating Based on Conditions

How to Use Excel VBA to Hide Columns Based on Cell Value (15 Examples) - ExcelDemy
How to Use Excel VBA to Hide Columns Based on Cell Value (15 Examples) - ExcelDemy

Now, let's explore how to update column values based on conditions.

Let's say we want to give employees who've worked for over 5 years an annual bonus. Here's how you'd achieve this:

AI Automation News
AI Automation News
Capped Column Snowflake
Capped Column Snowflake
Snowflake Data Modeling Guide: Boost Performance & Cut Costs
Snowflake Data Modeling Guide: Boost Performance & Cut Costs
Snowflake Data Governance: The Foundation of Secure, AI-Ready Data
Snowflake Data Governance: The Foundation of Secure, AI-Ready Data
Oracle vs. Snowflake
Oracle vs. Snowflake
a snowflake is shown in front of an upward arrow and chart lines on a dark background
a snowflake is shown in front of an upward arrow and chart lines on a dark background
📊 Snowflake Performance Tuning Guide
📊 Snowflake Performance Tuning Guide

```sql UPDATE EMPLOYEE SET SALARY = SALARY + 1000 WHERE DISBURSEMENT_DATE < DATE_SUB(CURRENT_DATE(), INTERVAL 5 YEAR); ```

Conditions with OR and AND Operators

You can use the AND, OR, and NOT operators to create complex conditions. For instance, let's give employees an annual bonus only if they've worked for more than 5 years AND their department is 'IT':

```sql UPDATE EMPLOYEE SET SALARY = SALARY + 1000 WHERE DISBURSEMENT_DATE < DATE_SUB(CURRENT_DATE(), INTERVAL 5 YEAR) AND DEPARTMENT = 'IT'; ```

Conditions with Subqueries

You can also use subqueries in your conditions. Suppose we want to give an annual bonus to employees who've worked for more than 5 years and earn less than the average salary in their department:

```sql UPDATE EMPLOYEE E SET SALARY = SALARY + 1000 WHERE DISBURSEMENT_DATE < DATE_SUB(CURRENT_DATE(), INTERVAL 5 YEAR) AND SALARY < ( SELECT AVG(SALARY) FROM EMPLOYEE E2 WHERE E.DEPARTMENT = E2.DEPARTMENT ); ```

Always remember to test your updates thoroughly and back up your data before performing large-scale updates. Snowflake's ability to update column values based on conditions offers a powerful tool to manage your data effectively. Happy updating!