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 / vishvajeet solanke
TRY THIS ONE..ITS SIMPLE
CREATE VOLATILE TABLE TEST
(e_NAME VARCHAR(10),SUB1 INTEGER,SUB2 INTEGER,SUB3 INTEGER)
ON COMMIT PRESERVE ROWS;
INSERT INTO TEST (e_NAME,SUB1,SUB2,SUB3) VALUES('AAA',85,95,92);
INSERT INTO TEST (e_NAME,SUB1,SUB2,SUB3) VALUES('BBB',75,67,82);
SEL E_NAME,MAX(SUBJECT) FROM
(SEL E_NAME,SUB1 AS SUBJECT
FROM TEST
UNION
SEL E_NAME,SUB2 AS SUBJECT
FROM TEST
UNION
SEL E_NAME,SUB3 AS SUBJECT
FROM TEST
) TS
GROUP BY 1
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are the things to be considered while creating secondary index?
What do you mean by teradata sql assistant?
How is MLOAD Teradata Server restarted after execution?
How can bottlenecks be identified?
How to identify ppi columns?
What are teradata utilities?
What are the frequently used data types in teradata?
List the logical and conditional operators that are used with teradata along with their meanings?
What is teradata and why it is used?
What is meant by a node?
Can you fastexport a field, which is primary key by putting equality on that key?
Describe the set operators in teradata.
What is the basic syntax for teradata select statement?
Explain the new features of teradata?
What do you mean by caching in teradata?