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 |
what is mapping parameter?
What is degenerated dimention table?
Design time, run time. If you don't create parameter what will happen
How do you load more than 1 max sal in each department through informatica or write sql query in oracle?
What will happen if the select list columns in the custom override sql query and the output ports order in sq transformation do not match?
hi i want to install latest informatica software in my pc..can anybody help me where should i get the infomatica software..plz help me
Can we use Lookup instead of Joiner to join 2 tables? If yes which is faster and why?
What is the main purpose of Unconnected lookup other than updating slowly changing dimensions? or In which case u use Unconnected lookup?
my source is like this id,name sal 10 abc 1000,10 pqr 2000, 10 xyz 3000 ,10 jkl 4000 and my requirement is like this 10 abc,pqr,xyz,jkl 2000 .... i have try for this by using expression transformatin its ok of the concatenation of second column but the thing is that on third column if u group by using agg t/r the last value will com i.e 4000 but i asked by a interviewer that i dont want the first or last column i want the middle column i.e 2000 .plz reply for the same
how lookup transformation is made active in new versions... When to use connected and when to use unconnected lookup and why? which is good for session performance. How to make lookup persistent and how to remove stale data from that lookup. how commit works - when we stop or abort data. Explain in both cases. What is factless fact table and have you ever used it in real time scenarios.
If the records doesnt satisfy the filter condition where will it go?
i have different sources in different databases ,that sources may be 100 tables i want to load these tables in to single target how to pearform the task