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

scenario where i can use only concurrent execution of workflow.

2552


What is a stored procedure transformation?

611


How to elaborate tracing level?

689


How to generate sequence numbers without using the sequence generator transformation?

649


What is meant by query override?

640






Separate from an archive server and a powerhouse?

500


explain about unit testing? in real time?

1674


What is a sorter transformation?

669


Plz can any one say me how to get the informatica certification materials and dumps

1602


Why can't we connect source qualifier and aggrigator transformation to an expression ? Why they resticted to conncet 2 active trasformations to an passive transformation ?

1749


Is stop and abort are same in informatica?

574


Tell me about MD5 functions in informatica

530


Hi, I want to change date type char value integer value? I tried alter table tab_name modify (newcolumn newdatetype). But The columns have 10 million values(char type) so I want to load now numeric data. How it is possible? Old Values New Value(I want to load numeric data but the old value should be there in the column) Y 1 N 0 ERROR at line 1: ORA-01439: column to be modified must be empty to change datatype Please help on this. Thanks, GM

3455


How do you migrate data from one environment to another?

651


Suppose on 1st Nov 2010 you had created a mapping which includes huge aggregator calculations and it is under process for next two days. You will notice that even on 3rd day also its still calculating. So without changing a logic or changing a mapping How will you troubleshot or to run that mapping? Explain the steps

1631