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
Explain how spool space is used.
Different phases of multiload?
How many codd's rules are satisfied by teradata database?
How can bottlenecks be identified?
How can we check the version of Teradata that we are using currently?
How to view every column and the columns contained in indexes in teradata?
Is multi insert ansi standard?
What do you mean by tpt in teradata?
what are the uses of fact table and dimension table in banking project?
How to explain project Architecture and flow in teradata interviews?Can please anyone help on this? Am new to teradata.
What is the difference between union and union all in teradata?
Highlight the need for Performance Tuning.
Highlight the differences between Primary Key and Primary Index.
how do you manage the production space. what are the proactive methods you can take ?
What are normalization, first normal form, second normal form and third normal form?