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
What is basic teradata query language?
What are the various indexes in teradata? How to use them?
Explain the term 'primary key' related to relational database management system?
In the Primary Index, what is the score of AMPs that are actively involved?
What are the newly developed features of Teradata?
How do you determine the number of sessions?
What are the functions involved in shared information architecture?
What are normalization, first normal form, second normal form and third normal form?
Difference between star and snowflake schemas?
Explain some differences between mpp and smp?
What is multi insert?
What is meant by a Highest Cost Plan?
What is a clique?
What are the commands to make a new table, change a table and remove a table in teradata?
Explain the term 'columns' related to relational database management system?