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 transformation?

655


Explain the code page compatibility?

636


How do you load only null records into target? Explain through mapping flow.

1492


Reusable transformation and shortcut differences

1371


explain about unit testing? in real time?

1651






What is a sequence generator transformation?

570


What is the difference between informatica 7.0 and 8.0?

561


What are the different lookup cache(s)?

614


scenario where i can use only concurrent execution of workflow.

2536


Explain about Informatica server process that how it works relates to mapping variables?

618


While importing the relational source definition from the database, what are the metadata of source that will be imported?

784


How can you differentiate between powercenter and power map?

619


What are ETL Tools?

662


What are the different ways to implement parallel processing in informatica?

858


Source and Target are flat files, Source table is as below ID,NAME 1,X 1,X 2,Y 2,Y On Target flat file i want the data to be loaded as mentioned below ID,NAME,REPEAT 1,X,2 1,X,2 2,Y,2 2,Y,2 How to achieve this, Can i get a map structure

6465