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 do we write scripts in unix how to execute scripts in real time anybody please needfull or give me number i will cal u
What are the various indexes in teradata? Why are they preferred?
Backup Script was blocked then you are unable to archive the data. how do you analyze it and where do you identify ?
Why is the case expression used in teradata?
During the Display time, how is the sequence generated by Teradata?
What is difference between user and database in teradata?
What are the different table types that are supported by teradata?
if collect stats but it show low confidence why?
Explain the teradata primary index mechanics in detail with a diagram.
What is the syntax for case when statement?
How can bottlenecks be identified?
what are the uses of fact table and dimension table in banking project?
Why are oltp database designs not generally a good idea for a data warehouse?
In general, how do you optimze any sql in teradata?
Explain the term 'tables' related to relational database management system?