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

Hi 2 every one. i dont have real time experience, and please suggest me for following questions. a) we get the source data from what type of source systems? b) In banking domain project what are the FACT & DIMENTION tables please list out them? c) please write some colomn names in a table? Please reply for aboue questions?..... Thanks in advance.

1 Answers   Amdocs,


What do you understand by a term domain?

0 Answers  


What is workflow variable? When we use workflow variable? Can any one explain me with one example???

2 Answers   TCS,


What is Test load plan? Let us assume 10 records in source, how many rows will be loaded into target?

3 Answers   Logica CMG,


Hello , I am unable to work with SQL transformation at least. Where do i need to give connection for sql transformaton ? At session level there is no property . I have created a SQL Transformation and chosen query mode. But do i need to pass connection information to it ? I don't know where do i need to write a query ? I have written a query in file and that file path i gave in the properties of SQL Transformation. But it is not working. Could any one of you please let know how can i work with SQL Transformation? Advance Thanks.

0 Answers   IBM,






What is an expression transformation in informatica?

0 Answers  


What is the Difference between sorter and aggregator?

2 Answers  


After we make a folder shared can it be reversed?Why?

2 Answers   Accenture,


source is a flat file empname, empno, sal ram, 101, 1,000 sam, 102, 2,000 ques: my target needs the data to be loaded as sal -1000 and 2000 excluding commas target empname, empno, sal ram, 101, 1000 sam, 102, 2000 how to implement this?

5 Answers   Polaris,


in mapping i have one source and five targets in that data will be loaded into four targets properily in one target the data is not loaded how will u rectify

3 Answers   Patni,


what is the diff b/w union and joiner and lookup?

4 Answers  


If you done any modifications for a table in back end does it reflect in informatca warehouse or maping?

2 Answers  


Categories