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 / hariharan
sel
studentid,
studentname,
case
when subject1>subject2 and subject1>subject3
then subject1
when subject2>subject1 and subject2>subject3
then subject2
when subject3>subject1 and subject3>subject2
then subject3
end as high_score,
case
when high_score = subject1
then 'subject1'
when high_score = subject2
then 'subject2'
when high_score = subject3
then 'subject3'
end as subject_name
from stud1
order by 1,2
;
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is the use of having index on table?
What are the steps involved in the process flow of the sql statement through channel attached system?
Why are oltp database designs not generally a good idea for a data warehouse?
How would you load a very large file in teradata in general? What utility would you use for it? Why?
What are the various etl tools in the market?
What are the primary characteristics of the Teradata.
What does sleep function does in fast load?
How do you do backup and recovery in teradata?
What is database exceptions in teradata?
Different phases of multiload?
What is the command in bteq to check for session settings ?
List out some of the primary characteristics of teradata.
Explain the parallel data extension in teradata?
What are some primary characteristics of teradata?
What are the things to be considered while creating secondary index?