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
How would you load a very large file in teradata in general? What utility would you use for it? Why?
What can be achieved by using the teradata rdbms?
Why does varchar occupy 2 extra bytes?
What is the use of fallback?
Explain teradata utilities. What is multiload, fast load, tpump?
Is multi insert ansi standard?
What are teradata utilities?
What is the use of having index on table?
How many codd's rules are satisfied by teradata database?
What are different table types used in teradata?
What is node? How many nodes and amps used in your previous project?
Explain teradata utilities?
why use references rather than pointers in the public api, particularly for arguments which are modified?
Different phases of multiload?
What are the available primary index types in teradata.