kalyan


{ City }
< Country > india
* Profession *
User No # 73491
Total Questions Posted # 0
Total Answers Posted # 3

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 41
Users Marked my Answers as Wrong # 10
Questions / { kalyan }
Questions Answers Category Views Company eMail




Answers / { kalyan }

Question { Accenture, 7316 }

write sql query following source table

jan feb mar apr
100 200 300 400
500 600 700 800
900 100 200 300
i want the output format like

month total
jan 1500
feb 900
mar 1200
apr 1500


Answer

Hi, Using UNION ALL ,You can achieve it, here is Your Query

SELECT 'JAN' AS MONTH, SUM(JAN) AS TOTAL FROM SRC_MONTHS
UNION ALL
SELECT 'FEB' AS MONTH, SUM(FEB) AS TOTAL FROM SRC_MONTHS
UNION ALL
SELECT 'MAR' AS MONTH, SUM(MAR) AS TOTAL FROM SRC_MONTHS
UNION ALL
SELECT 'APR' AS MONTH, SUM(APR) AS TOTAL FROM SRC_MONTHS

Thanks
Kalyan Sankuthula

Is This Answer Correct ?    23 Yes 0 No

Question { Tech Mahindra, 10836 }

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


Answer

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


Question { Emphasis, 8020 }

Why the UNION TRANSFERMATION is an Active TRANSFERMATION


Answer

In Union Transformation we may combine the data from two
(or) more sources. Assume Table-1 contains '10' rows and
Table-2 contains '20' rows. If we combine the rows of
Table-1 and Table-2 we will get a total of '30' rows in the
Target. So it is definitely an Active Transformation.

Is This Answer Correct ?    9 Yes 5 No