SQL Case Statement: Simple vs Searched vs Nested

Описание к видео SQL Case Statement: Simple vs Searched vs Nested

#SQL In this SQL tutorial, we will go over the different types of Case statements: Simple, Searched, and Nested Case statements. We will also cover some examples to demonstrate the use of each.

Queries Used in The Tutorial:
-- Create the Score table
CREATE TABLE Score (
Student_ID INT,
Student_Name VARCHAR(50),
Student_Status VARCHAR(10),
Score int
);

-- Insert sample data into the Score table
INSERT INTO Score (Student_ID, Student_Name, Student_Status ,Score)
VALUES
(1, 'Rebecca Laszlo','Active', 92),
(2, 'Jane Smith','Active', 78),
(3, 'Michael Raheem','Inactive', 85),
(4, 'Alice Brown','Active',55),
(5, 'Eva Wilson','Active',96),
(6, 'Michelle Brown','Active',80),
(7, 'Don Lee','Inactive',80)
(8, 'John Wolf',null,85)

--Simple Case Statement
select
Student_ID,
Student_Name,
Student_Status,
score,
case
student_status
when 'active' then 'A'
when 'inactive' then 'I'
else 'unknown'
end as Grade
from score


#datascience #coding #programming #mssql #databasemanagement

👉SQL Tutorials Playlist:
   • SQL Tutorials  

👉SQL Shorts Playlist:
   • SQL Shorts  

👉Python Shorts Playlist:
   • Python Shorts  

👉Python Tutorials Playlist:
   • Python Tutorials  

👉Excel Shorts Playlist:
   • Excel Shorts  

Комментарии

Информация по комментариям в разработке