0% found this document useful (0 votes)
16 views7 pages

SQL CASE Statement for Student Grades

SQL case statement

Uploaded by

Shipra
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views7 pages

SQL CASE Statement for Student Grades

SQL case statement

Uploaded by

Shipra
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SQL

CASE
Statement
in SQL
Pradeep M
@pradeep-m-analyst
The CASE statement in SQL is used to add
conditional logic to SQL queries.

It evaluates conditions and returns results


based on which condition is true.
For example, let’s consider a simple table
named Students:

StudentID Name Grade

1 Pankaj 85

2 Karthika 90

3 Ramesh 78

4 Priyank 92
Now, let’s use a CASE statement to
categorize students based on their grades:
OUTPUT
Name Grade GradeLetter

Pankaj 85 B

Karthika 90 A

Ramesh 78 C

Priyank 92 A
In this example, the CASE statement checks
the Grade for each record in the Students
table.

If the grade is 90 or above, it returns ‘A’.

If the grade is 80 or above but less than


90, it returns ‘B’.

If the grade is less than 80, it returns ‘C’.


Did you find this
valuable?
If you find my post valuable, Could you please
show your support by giving me a like?

Pradeep M
@pradeep-m-analyst

You might also like