YOUR AD GOES HERE

CASE Statement IN SQL Queries #shorts

Published 09, Feb 2023

D. S. Pandit books


Description:
#sql #sqlcommands #sqlqueries #sqlquery #dbmslectures #structuredquerylanguage

/*Please review the scripts and use only on test or dummy database*/


CREATE TABLE mycasetable
(Standard SMALLINT,
StudentCount SMALLINT);


INSERT into mycasetable values
(1, 35),(2,30),(3,30),(4,25),
(5,40),(6,45),(7,40),
(8,55),(9,50),(10,55);



SELECT * from mycasetable;


SELECT
CASE WHEN Standard BETWEEN 1 AND 4 THEN 'Primary'
WHEN Standard BETWEEN 5 AND 7 THEN 'Secondary'
WHEN Standard BETWEEN 8 AND 10 THEN 'Higher Secondary'
ELSE 'Other Section' END as Section, SUM(StudentCount) as cnt from mycasetable
GROUP BY 1
ORDER BY MIN(Standard);

Releted More Videos

  • Sorry!!! Nothing to show

You May Also Like

YOUR AD GOES HERE

YOUR AD GOES HERE