wtite sql query following table are
city gender no
chennai male 40
chennai female 35
bangalore male 10
bangalore female 25
mumbai female 15
i want the output?

city male female
chennai 40 35
bangalore 10 25
mumbai null 15

Answers were Sorted based on User's Feedback



wtite sql query following table are city gender no chennai male 40 chennai female ..

Answer / santosh kumar sarangi

select city,max(decode(gender,'male',no)) as male,
max(decode(gender,'female',no)) as female from table_name
group by city

Is This Answer Correct ?    1 Yes 0 No

wtite sql query following table are city gender no chennai male 40 chennai female ..

Answer / gagan

Suppose first table as test created below create table test
(
city varchar2(50),
gender varchar2(50),
nmbr varchar2(50)
)

and keep all data in it as mentioned and then try to run
this query...


select a.city, a.nmbr as male, b.nmbr as female
from test a, test b
where a.gender = 'male' and b.gender = 'female' and b.city
= a.city

Is This Answer Correct ?    2 Yes 2 No

wtite sql query following table are city gender no chennai male 40 chennai female ..

Answer / gagan

Suppose first table as test created below...

create table test
(
city varchar2(50),
gender varchar2(50),
nmbr varchar2(50)
)

and keep all data in it as mentioned and then try to run
this query...


select a.city, a.nmbr as male, b.nmbr as female
from test a, test b
where a.gender = 'male' and b.gender = 'female' and b.city
= a.city

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Informatica Interview Questions

If I am having 6 flat files in data. How can you load the data at a time

2 Answers   CSC,


How does a sorter cache works?

0 Answers  


I am having source ENO ENAME LOC 1 A PUNE 2 B MUMBAI 3 C CHENNAI Target ENO ENAME LOC 1 A PUNE 2 B MUMBAI 3 C CHENNAI If a new record coming from source from same location it should directly go to specified location in target at begining EX:if Eno with 4 coming from same Pune, It should directly load into the Pune location col with '|' symbol. Help me its very urgent

5 Answers   Polaris, Zensar,


what is the difference between stop and abort?

3 Answers   TCS,


hi, as al you know, we can set the option in session level as all rows treat as like insert,update etc., And also we have update strategy for flaging records as insert,update etc.. then when we will go for above options and what is the difference.. explain..

1 Answers   Wipro,






how the server recognises , if the session fails after loading the 100 records in to the target

2 Answers   TCS,


What are the prerequisite tasks to achieve the session partition?

0 Answers  


What is primary and backup node?

0 Answers  


What is a pre-defined event and user-defined event?

0 Answers  


can we see default group,when we use router?if yes how?

2 Answers   L&T,


In Joiner Transformation, how to identify the master and detail tables if one is from Oracle and the other is from Sybase.

2 Answers   TCS,


What is the function of aggregator transformation?

0 Answers  


Categories