how to achieve this problem?i am having table with two
colums like empno,gender.
in gender column, i am having records male,female like that
.my final output will be
male female
5 6

Answers were Sorted based on User's Feedback



how to achieve this problem?i am having table with two colums like empno,gender. in gender column..

Answer / shivaindu

SQL> select sum(decode(gender, 'male', 1)) as Male,
sum(decode(gender, 'female', 1)) as Female from
emp1;

MALE FEMALE
---------- ----------
9 7

Is This Answer Correct ?    16 Yes 1 No

how to achieve this problem?i am having table with two colums like empno,gender. in gender column..

Answer / jayakrishnan

select count(case gender when 'male' then 1 end) Male,
count(case gender when 'female' then 1 end) Female from emp1

Is This Answer Correct ?    5 Yes 1 No

how to achieve this problem?i am having table with two colums like empno,gender. in gender column..

Answer / sudeep ranjan

select gender,count(gender)as gender_count from emp group
by gender;

Is This Answer Correct ?    5 Yes 1 No

how to achieve this problem?i am having table with two colums like empno,gender. in gender column..

Answer / venkat

select Count(gender) from emp group by gender with rollup

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

What is Difference Between Unique and Primary Key Constraints?

0 Answers   Wipro,


How insert into statements in sql?

0 Answers  


Can we use SQL%ISOPEN in implicit cursors? Does this attribute works properly in Implicit Curosors?

3 Answers  


why does the selected column have to be in the group by clause or part of an aggregate function? : Sql dba

0 Answers  


What is column?

0 Answers  






How do you declare a variable in pl sql?

0 Answers  


What is an escape character in sql?

0 Answers  


What do we need to check in database testing?

0 Answers  


If I have a table T with 4 rows & 2 columns A & B. A has values 1,2,3,4. and B has 10,20,30,40. Write an Update SQL query which can Swap the values of A & B for all records. (Do not use a sub-query)

5 Answers  


what is difference between pass by value and eference by value in oracle plsql

1 Answers  


write a query to display diference between two dates in sql server

2 Answers  


What are sql functions? Describe the different types of sql functions?

0 Answers  


Categories