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
  
 
117
  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

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 TrainingApr 01 to Apr 16
Snowflake TrainingApr 04 to Apr 19
Snowflake TrainingApr 08 to Apr 23
Snowflake TrainingApr 11 to Apr 26
Last updated: 30 March 2023
About Author
Remy Sharp
SaiKumar Kalla

Kalla Saikumar is a technology expert and is currently working as a content associate at MindMajix. Write articles on multiple platforms such as ServiceNow, Business Analysis, Performance Testing, Mulesoft, Oracle Exadata, Azure, and other courses. And you can join him on LinkedIn.

Recommended Courses

1 /10