write sql query following table

city gender no
chennai male 40
chennai female 35
bangalore male 25
bangalore female 25
mumbai female 15

i want the required output

city male female
chennai 40 35
bangalore 25 25
mumbai 15

Answers were Sorted based on User's Feedback



write sql query following table city gender no chennai male 40 chennai female 35 ..

Answer / chanakya

SELECT CITY,
SUM(DECODE(GENDER,'MALE',NO)) MALE ,
SUM(DECODE(GENDER,'FEMALE',NO)) FEMALE
FROM TABLE_NAME GROUP BY CITY

Is This Answer Correct ?    9 Yes 5 No

write sql query following table city gender no chennai male 40 chennai female 35 ..

Answer / venky

select city,sum(c1) male,sum(c2) female from(select
city,decode(gender,'male',no,0)
c1,decode(gender,'female',no,0) c2 from tablename) tablename
group by city;

Is This Answer Correct ?    4 Yes 3 No

write sql query following table city gender no chennai male 40 chennai female 35 ..

Answer / sudheer

Select ABC.CITY AS CITY, sum(ABC.male) as MALE, sum(ABC.Female) as FEMALE from

(
select city, Sum(no) as male, NULL AS female from table_name
where gender = 'male'
Group by city

UNION

select city, NULL as male, SUM(no) AS female from table_name
where gender = 'female'
Group by city

) ABC Group by CITY

Is This Answer Correct ?    0 Yes 0 No

write sql query following table city gender no chennai male 40 chennai female 35 ..

Answer / anshita gupta

select * from city pivot(max(no) for gender in('male ','female'));

Is This Answer Correct ?    0 Yes 0 No

write sql query following table city gender no chennai male 40 chennai female 35 ..

Answer / venu

select* from tablename

Is This Answer Correct ?    1 Yes 5 No

Post New Answer

More Informatica Interview Questions

What is souce qualifier transformation it is active or passive

2 Answers   HCL,


What is source qualifier transformation in informatica?

0 Answers  


What is the term PIPELINE in informatica ?

7 Answers   Deloitte,


Hi all, iam new to informatica, can anyone tell me what is unit testing & how it is done? thank u

3 Answers  


what is casual dimension?

6 Answers   IBM,






Can we make worklet inside worklet?

1 Answers  


How can you complete unrcoverable sessions?

1 Answers  


What is a node in Informatica?

0 Answers  


What is batch and describe about types of batches?

2 Answers  


explain one complex mapping with logic? sales project?

0 Answers   Accenture, JPMorgan Chase,


What are the informatica performance improvement tips

0 Answers   Informatica,


Hi i am new to Informatica. I have few question's in Informatica. Can any one respond, it will be appricaited. Q.Is Flat File Contains the Dynamic Cache?

6 Answers  


Categories