Home  >  Blog  >   Snowflake  > 

How to Write a Case Statement in Snowflake

In Snowflake, we will use the “Case” statement for working with the “if” statement in the “Select” statement. This blog illustrates writing the case statement through an example.

Rating: 4.6
  
 
303
  1. Share:
Snowflake Articles

Write a Case Statement in Snowflake

We use “CASE” statements while reaching for the "IF" statement in our "SELECT" clause.

Select
id1,
name1,
percentage,
Grade,
case
when percentage = 35 then ‘pass’
when percentage = 60 then ‘first class’
when percentage = 75 then ‘distinction’
when percentage >= 95 then ‘excellent’
else ’fail’
end as good_marks
From students

MindMajix Youtube Channel

Conclusion

We will write a “Case” statement in the “Select” statement to work with the “if” statement. I hope this helps you use the “Case” statement in the “if” statement.

Snowflake Related Articles


▶  Snowflake vs Redshift
▶  Snowflake vs BigQuery
▶  Snowflake vs Databricks
▶  Snowflake vs Azure
▶  Snowflake vs Hadoop
▶  Snowflake Time Travel

If you have any queries, let us know by commenting below.

Join our newsletter
inbox

Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!

Course Schedule
NameDates
Snowflake TrainingAug 05 to Aug 20
Snowflake TrainingAug 08 to Aug 23
Snowflake TrainingAug 12 to Aug 27
Snowflake TrainingAug 15 to Aug 30
Last updated: 04 August 2023
About Author
Remy Sharp
SaiKumar Kalla

Kalla Saikumar is a technology expert and is currently working as a Marketing Analyst at MindMajix. Write articles on multiple platforms such as Tableau, PowerBi, Business Analysis, SQL Server, MySQL, Oracle, and other courses. And you can join him on LinkedIn and Twitter.

Recommended Courses

1 /10