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 spool space? Why do you get spool space errors? How do trouble-shoot them?
What are default access rights in teradata?
Difference between star and snowflake schemas?
What is the use of teradata system software?
Is it necessary to add? Quit statement after a bteq query when I am calling it in a unix environment?
What is meant by a Clique?
Why does varchar occupy 2 extra bytes?
What are the advantages of teradata?
Hi, If anyone has TD 14 Basics dumps or study materials, please share. nirmaaal1991@gmail.com
Mention the procedure via which, we can run Teradata jobs in a UNIX environment.
What are the joins in teradata and how many types of joins are there in teradata?
While creating table my dba has fallback or no fallback in his ddl. What is that?
What is meant by a Channel Driver?
What is basic teradata query language?
What are the scenarios in which full table scans occurs?