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 / alok

Just optimized Hariharan's And


SEL A.STUDENTID,A.STUDENTNAME,
CASE WHEN A.HIGHSUBJ='SUBJECT1'
THEN A.SUBJECT1
END AS SUBJECT1,
CASE WHEN A.HIGHSUBJ='SUBJECT2'
THEN A.SUBJECT2
END AS SUBJECT2,
CASE WHEN A.HIGHSUBJ='SUBJECT3'
THEN A.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
ORDER BY A.STUDENTID ;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

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

587


What can be achieved by using the teradata rdbms?

616


Why does varchar occupy 2 extra bytes?

598


What is the use of fallback?

547


Explain teradata utilities. What is multiload, fast load, tpump?

560






Is multi insert ansi standard?

1740


What are teradata utilities?

577


What is the use of having index on table?

574


How many codd's rules are satisfied by teradata database?

653


What are different table types used in teradata?

577


What is node? How many nodes and amps used in your previous project?

662


Explain teradata utilities?

558


why use references rather than pointers in the public api, particularly for arguments which are modified?

544


Different phases of multiload?

584


What are the available primary index types in teradata.

579