SQL Interview Questions | Separate DOB Data of Employess
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
It will take less than 1 minute to register for lifetime. Bonus Tip - We don't send OTP to your email id Make Sure to use your own email id for free books and giveaways
Answers ( 6 )
SELECT COUNT(*),
sex from Employees
WHERE DOB BETWEEN ’01/07/1965′ AND ’31/12/1975′
GROUP BY sex;
SELECT sex, COUNT(*) from Employees GROUP BY sex WHERE DOB BETWEEN ’01/07/1965′ AND ’31/12/1975′ ;
Correction:
select sex, COUNT(*) from Employees where DOB between ’01/07/1965′ AND ’31/12/1975′ group by sex ;
select gender, count(employees)
from employees
where dob between ’01/07/1965′ and ’31/12/1975′
group by gender
SELECT COUNT(*) AS SEX FROM EMPLOYEES
WHERE DOB BETWEEN ‘1965-07-01′ AND 1965-12-31’
GROUP BY GENDER
Select Count(*) ,Sex from Employees
WHERE DOB BETWEEN CAST(‘1965-07-01’ as Date) AND CAST(‘1965-12-31’ as Date)
Note: When you use Between operator with Date Values, It is better to use with CAST Function to get better results.CAST Function helps us to convert the Type of column or expression to the Date Type.
Select sex , count(1) as No_of_emp from employee
where DOB Between ’01/07/1965′ AND ’31/12/1975′
Group By sex;