Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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



write sql query following table city gender no chennai male 40 chennai female 35 ..

Answer / chanakya

SELECT CITY,
SUM(DECODE(GENDER,'MALE',NO)) MALE ,
SUM(DECODE(GENDER,'FEMALE',NO)) FEMALE
FROM TABLE_NAME GROUP BY CITY

Is This Answer Correct ?    9 Yes 5 No

write sql query following table city gender no chennai male 40 chennai female 35 ..

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

write sql query following table city gender no chennai male 40 chennai female 35 ..

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

write sql query following table city gender no chennai male 40 chennai female 35 ..

Answer / anshita gupta

select * from city pivot(max(no) for gender in('male ','female'));

Is This Answer Correct ?    0 Yes 0 No

write sql query following table city gender no chennai male 40 chennai female 35 ..

Answer / venu

select* from tablename

Is This Answer Correct ?    1 Yes 5 No

Post New Answer

More Informatica Interview Questions

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.

5 Answers   Accenture, VAMA,


What is Data Caches size?

0 Answers   Informatica,


scenario

1 Answers  


Global and Local shortcuts. Advantages.

0 Answers  


what are the different types of transformation available in informatica. And what are the mostly used ones among them?

0 Answers  


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.

3 Answers  


How to eliminate 1st and last rows from the source and load the inbetween rows.

5 Answers   Syntel,


how the data will be loaded while desiging the schema?which one first (for e.g.-dimesions and facts)

2 Answers   Sonata,


Can anyone tell me the new features in Informatica 9 Version?

2 Answers   Syntel,


How will you convert rows into columns or columns into rows

1 Answers  


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?

5 Answers   Polaris,


Is it passive or active when check and uncheck the box of DISTINCT in Sorter transformation? why?

6 Answers   iFlex, Morgan Stanley,


Categories