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 / mahesh raja
SEL STUDENTID,STUDENTNAME,MARKS, SBJ,RANK()OVER (PARTITION
BY STUDENTID ORDER BY MARKS DESC ) AS RANK1 FROM
(
SEL STUDENTID,STUDENTNAME,SUBJECT1 AS MARKS, 'SUB1' AS SBJ
FROM STUD1
UNION
SEL STUDENTID,STUDENTNAME,SUBJECT2 AS MARKS, 'SUB2' AS SBJ
FROM STUD1
UNION
SEL STUDENTID,STUDENTNAME,SUBJECT3 AS MARKS, 'SUB3' AS SBJ
FROM STUD1
)A QUALIFY RANK1=1
| Is This Answer Correct ? | 9 Yes | 0 No |
Post New Answer View All Answers
What is meant by a Highest Cost Plan?
What are the steps involved after the disk manager passes the request?
If the PMON is not working then how do you manage and monitor all processes, resources and sessions etc.
If Fast Load Script fails and only the error tables are made available to you, then how will you restart?
What is a dimension table?
What are the design features involved in teradata?
Explain the new features of teradata?
What are aggregate tables? How do you design them using teradata?
Can you fastexport a field, which is primary key by putting equality on that key?
What is teradata? What are some primary characteristics of teradata?
What are the different methods ot loading a dimension table? A fact table etc?
how can we analyze the locks ?
why use references rather than pointers in the public api, particularly for arguments which are modified?
What are the different functions performed in development phase?
What is TPD?