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
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 |
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 |
Answer / anshita gupta
select * from city pivot(max(no) for gender in('male ','female'));
Is This Answer Correct ? | 0 Yes | 0 No |
What is souce qualifier transformation it is active or passive
What is source qualifier transformation in informatica?
What is the term PIPELINE in informatica ?
Hi all, iam new to informatica, can anyone tell me what is unit testing & how it is done? thank u
what is casual dimension?
Can we make worklet inside worklet?
How can you complete unrcoverable sessions?
What is a node in Informatica?
What is batch and describe about types of batches?
explain one complex mapping with logic? sales project?
0 Answers Accenture, JPMorgan Chase,
What are the informatica performance improvement tips
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?