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
What are the uses of client software involved in teradata?
Name the five phases that come under MultiLoad Utility.
What is spool space?
What is partitioned primary index (ppi)?
What are default access rights in teradata? What explicit right can be given to a user?
Describe the set operators in teradata.
Explain Teradata performance tuning and optimization?
What is the purpose of upsert command?
Why do you get spool space errors? How do trouble-shoot them?
Difference between stored procedure and macro?
What is node? How many nodes and amps used in your previous project?
Difference between star and snowflake schemas?
What is meant by a dispatcher?
What is a clique?
What is meant by a Channel Driver?