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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a mapplet/worklet in informatica?

815


how tokens will generate?

1840


Briefly describe lookup transformation?

667


Can informatica load heterogeneous targets from heterogeneous sources?

814


What are the different lookup cache(s)?

712






Suppose we do not group by on any ports of the aggregator what will be the output?

683


How many ways a relational source definition can be updated and what are they?

664


permutations of mapplet

2138


1)you have multiple source system where u receive files ,how do you actually load into mapping using transformation,what are the transformation you use? 2)you have files in ftp location ,how do you get it into mapping with you ETL concept?

1772


Can you use flat files in Mapplets.

2312


How to create or implement slowly changing dimension (SCD) Type 2 Effective Date mapping in informatica/Flagging mapping in informatica/visioning mapping in informatica?

791


What are the tasks that source qualifier perform?

722


What is meant by lookup transformation?

698


Please let me know how to make encryption and decryption with example?

1571


what are the best practices to extract data from flat file source which are bigger than 100 mb memory?

2020