Back to Browse

Oracle SQL TUTORIAL – IF condition using CASE and DECODE - An Example

8.5K views
Oct 9, 2018
9:31

In this video, we shall see how case and decode is used in real time scenario. SQL used in the video is given below. SELECT * FROM emp_test ORDER BY gender; count_of_employees Count_of_Male_Employees Count OF Female Employees -- 15 5 8 select count(*) " Total Employees" from emp_test; select gender,count(*) " Total Employees" from emp_test group by gender; select sum(decode(gender,'M',1,0)) Count_OF_Male_Employees from emp_test; select sum(case gender when 'F' then 1 else 0 end) as Count_OF_FeMale_Employees from emp_test; SELECT count(*) " Total Employees" , sum(decode(gender,'M',1,0)) Count_OF_Male_Employees, sum(case gender when 'F' then 1 else 0 end) Count_OF_Female_Employees from emp_test;

Download

1 formats

Video Formats

360pmp412.8 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Oracle SQL TUTORIAL – IF condition using CASE and DECODE - An Example | NatokHD