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
Can we have an unconnected lkp to lookup a db2 record against a teradata record? Doesnt seem to work. I could be wrong
What is the particular designated level at which a LOCK is liable to be applied in Teradata?
Different phases of multiload?
Why do you get spool space errors? How do trouble-shoot them?
What are the different table types supported by teradata?
What are the steps to create a data model?
how do you manage the production space. what are the proactive methods you can take ?
Explain teradata vs. Redshift?
What type of indexing mechanism do we need to use for a typical data warehouse?
In Teradata, how do we Generate Sequence?
how do we write scripts in unix how to execute scripts in real time anybody please needfull or give me number i will cal u
If the PMON is not working then how do you identify and monitor all the processes, resources and sessions ?
What is meant by a Channel Driver?
In Teradata, what is the significance of UPSERT command?
What are types of partition primary index (ppi) in teradata?