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
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 |
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 |
Answer / anshita gupta
select * from city pivot(max(no) for gender in('male ','female'));
| Is This Answer Correct ? | 0 Yes | 0 No |
which one is better performance wise joiner or look up
Source is a flat file and want to load unique and duplicate records separately into two separate targets; right??
i have a source table ID NAME SAL 101 A 1000 102 B 2000 103 C 1500 target load should be ID NAME SAL 101 A 1000 101 B 2000 101 C 1500 102 A 1000 102 B 2000 102 C 1500 103 A 1000 103 B 2000 103 C 1500
write a query to get maximum salary from the employers table without duplicates....kindly help me
In a simple mapping when i use aggregate t/r with out any condition or group by, i am getting output as only last record in the table . can any one explain it please.........?
If i have one source having 10 ports.In a mapping i use that source one target having that ten ports.Data from 5 ports are going to target through a mapplet and another 5 ports are going to target through another mapplet.Both 2 mapplets are intially passive in nature.But presently my requirment to convert on mapplet to ACtive.How can i do it.
How to prepared lld.can any one tell me detailed explanetion.
What is a unit Testing?
What are the components of the workflow manager?
What are parallel querys and query hints?
In Lookup transformation a sql override should be done and disable the cache how do you do this procedure?
Enlist some properties of sessions.