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

SELECT STUDENTID, STUDENTNAME,
CASE WHEN SUBJECT1>SUBJECT2 AND SUBJECT1>SUBJECT3
THEN SUBJECT1 END AS SUBJECT1,
CASE WHEN SUBJECT2>SUBJECT1 AND SUBJECT2>SUBJECT3
THEN SUBJECT2 END AS SUBJECT2,
CASE WHEN SUBJECT3>SUBJECT1 AND SUBJECT3>SUBJECT2
THEN SUBJECT3 END AS SUBJECT3
FROM STUD1;

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain Teradata performance tuning and optimization?

684


What is meant by a Highest Cost Plan?

613


Explain the meaning of Amp?

579


What is a level of granularity of a fact table?

635


Did you write stored procedures in teradata?

607






Explain the advantages of partitioned primary index in a query?

551


What are the steps to create a data model?

589


What are the frequently used data types in teradata?

585


What are tpump utility limitations?

586


What do you mean by teradata intelliflex?

618


Highlight the advantages of PPI(Partition Primary Index).

555


What is meant by a dispatcher?

553


Why does varchar occupy 2 extra bytes?

596


What is the difference between teradata and basic rdbms?

558


How can you track login parameters of users in teradata?

620