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 |
without matching columns in two tables. how can you join
What is a Shortcut and What is the difference between a Shortcut and a Reusable Transformation?
Under what condition selecting sorted input in aggregator may fail the session?
how can we check whether a particular cache is static or dynamic?
what is the hint? how to use it to reduce the query processing in program?
Without source how to insert record to target?
I have a flat file, want to reverse the contents of the flat file
I have a source file its is CSV(comma separated). I want to convert it to tab separated. Make sure the conversion happens on all commas except the ones enclosed in Double quotes .
Performance tuning( what you did in performance tuning)
Explain the flow of data in Iinformatica?
What are the restrictions of union transformation?
In real time scenario where can we use mapping parameters and variables?