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 |
Suppose we have a (assume relational) source table Product_Id Month Sales 1 Jan x 1 Feb x . . . . . . 1 Dec x 2 Jan x 2 Feb x . . . . . . 2 Dec x 3 Jan x 3 Feb x . . . . . . 3 Dec x . . . . . . and so on. Assume that there could be any number of product keys and for each product key the sales figures (denoted by 'x' are stored for each of the 12 months from Jan to Dec). So we want the result in the target table in the following form. Product_id Jan Feb March.. Dec 1 x x x x 2 x x x x 3 x x x x . . So how will you design the ETL mapping for this case , explain in temrs of transformations.
What is Data Caches size?
scenario
Global and Local shortcuts. Advantages.
what are the different types of transformation available in informatica. And what are the mostly used ones among them?
i have a source which relational.I am trying to populate to target flat file with one column for daily date which is sysdate. I want to populate the sysdate coulmn with DD/MM/YYYY format. kindly provide a solution for this..my clear that my target is flat file.
How to eliminate 1st and last rows from the source and load the inbetween rows.
how the data will be loaded while desiging the schema?which one first (for e.g.-dimesions and facts)
Can anyone tell me the new features in Informatica 9 Version?
How will you convert rows into columns or columns into rows
source is a flat file empname, empno, sal ram, 101, 1,000 sam, 102, 2,000 ques: my target needs the data to be loaded as sal -1000 and 2000 excluding commas target empname, empno, sal ram, 101, 1000 sam, 102, 2000 how to implement this?
Is it passive or active when check and uncheck the box of DISTINCT in Sorter transformation? why?
6 Answers iFlex, Morgan Stanley,