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
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 |
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 |
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 |
If I am having 6 flat files in data. How can you load the data at a time
How does a sorter cache works?
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
what is the difference between stop and abort?
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..
how the server recognises , if the session fails after loading the 100 records in to the target
What are the prerequisite tasks to achieve the session partition?
What is primary and backup node?
What is a pre-defined event and user-defined event?
can we see default group,when we use router?if yes how?
In Joiner Transformation, how to identify the master and detail tables if one is from Oracle and the other is from Sybase.
What is the function of aggregator transformation?