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...

i have column like below

studentid studentname sub1 sub2 sub3
1 aaa 40 70 90
2 bbb 60 80 50
i want to execute every student highest mark in which subject
my o/p like below
studentid studentname sub3 sub2
1 aaa 90
2 bbb 80

Answer Posted / tdguy

SEL A.STUDENTID,A.STUDENTNAME,
CASE WHEN A.HIGHSUBJ='SUBJECT1'
THEN A.SUBJECT1 ELSE C.SUBJECT1
END AS SUBJECT1,
CASE WHEN A.HIGHSUBJ='SUBJECT2'
THEN A.SUBJECT2 ELSE C.SUBJECT2
END AS SUBJECT2,
CASE WHEN A.HIGHSUBJ='SUBJECT3'
THEN A.SUBJECT3 ELSE C.SUBJECT3
END AS SUBJECT3
FROM
(SEL STUDENTID,STUDENTNAME,SUBJECT1 ,SUBJECT2 ,SUBJECT3,
CASE WHEN SUBJECT1 > SUBJECT2 AND SUBJECT1 > SUBJECT3
THEN 'SUBJECT1'
WHEN SUBJECT2 > SUBJECT3
THEN 'SUBJECT2' ELSE 'SUBJECT3'
END AS HIGHSUBJ
FROM STUD1) A
INNER JOIN
(SEL STUDENTID,STUDENTNAME,NULL AS SUBJECT1 ,
NULL AS SUBJECT2 ,NULL AS SUBJECT3 FROM STUD1) C
ON A.STUDENTID=C.STUDENTID
ORDER BY A.STUDENTID

Is This Answer Correct ?    12 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

any one answer me how they can analyzing the project using data ware housing?

2483


i learn teradata,it is so intersting,now i want teradata certifications ,so any 1 help me to get teradata certifications TD 12 ? email:kdcrazyy@gmail.com

2204


What is the purpose of joins in teradata?

1192


How is MLOAD Teradata Server restarted after execution?

1270


How many tables can you join in v2r5?

1075


tomorrow i have interview in infosys.can someone pour any suggestions or any interview questions. thank you

837


What are the design features involved in teradata?

1064


How would you load a very large file in teradata in general? What utility would you use for it? Why?

1105


What are the steps to create a data model?

1061


Backup Script was blocked you are unable to archive the data now. how do you analyze it and where do you identify ?

2052


Highlight the advantages of PPI(Partition Primary Index).

1079


What is meant by a Parsing Engine?

1191


If the PMON is not working then how do you identify and monitor all the processes, resources and sessions ?

2205


Explain and compare pros and cons of start schemas?

1073


What is oltp?

983