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 |
What exactly mentioned in High level design document.can somebody explain me sequentialy.
When the informatica server marks that a batch is failed?
what is galaxy repository?
If there are more than one sessions running parallel in a worklet, which will be the last session ?
what is casual dimension?
Two relational tables are connected to SQ Trans,what are the possible errors it will be thrown?
what is mystery dimension?
Is snow flake or star schema used? If star schema means why?
i have 1000 record flat file source i want 1st row to 1st target, 2nd row to 2nd target, 3rd row to 3rd target how will u do? Without using Mod Function? Explain....
Hi, What is version control in Informatia ? Can anyone just give an idea or introduction about this? Advance Thanks
i have a session which creates a file every time when i runs the session, but it replaces the first file with second file,i want to append the second file follwed by first file when i runs the session,how to achieve this?
what is the mechanism of the Master-Detail joining condition?