SQL Interview Questions | Get the appropriate result
Question
Name | Gender |
X | MALE |
XY | FEMALE |
XYZ | FEMALE |
Y | MALE |
YZ | FEMALE |
YZX | MALE |
Z | FEMALE |
The given table is a part of a larger table consisting data of people present in a meeting.
This data needs to be sorted and the output should be like this,
MALE | FEMALE |
3 | 4 |
Write the query accordingly.
in progress
0
SQL
55 years
1 Answer
1195 views
Great Grand Master 0
Answer ( 1 )
Select
SUM( CASE WHEN Gender =’Male’ then 1 else 0 END) as Male,
SUM ( CASE WHEN Gender =’Female’ then 1 else 0 END) as Female
from Table;