Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / yuvaevergreen

CREATE TABLE STUD1
(
STUDENTID CHAR(10), STUDENTNAME CHAR(10),
SUBJECT1 INTEGER, SUBJECT2 INTEGER,
SUBJECT3 INTEGER
)PRIMARY INDEX( STUDENTID );
INSERT INTO STUD1 VALUES ('1','A1',2,7,1);
INSERT INTO STUD1 VALUES ('2','A2',1,6,2);
INSERT INTO STUD1 VALUES ('3','A3',3,5,3);
INSERT INTO STUD1 VALUES ('4','A4',4,4,7);
INSERT INTO STUD1 VALUES ('5','A5',5,3,6);

QUERY TO FETCH THE STUDENTS TOPPED IN ALL THE THREE SUBJECTS

SEL STUDENTID,STUDENTNAME,SUBJECT1,SUBJECT2,SUBJECT3
FROM
(
SEL STUDENTID,STUDENTNAME,SUBJECT1,SUBJECT2,SUBJECT3,
RANK () OVER (ORDER BY SUBJECT1 DESC) as SUB1RANK,
RANK () OVER (ORDER BY SUBJECT2 DESC) as SUB2RANK,
RANK () OVER (ORDER BY SUBJECT3 DESC) as SUB3RANK
FROM STUD1 QUALIFY (SUB1RANK=1 OR SUB2RANK=1 OR SUB3RANK=1 )) A

Is This Answer Correct ?    7 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

There is a column with date in it. If I want to get just month how it can be done? Can I use sub string?

1062


why use references rather than pointers in the public api, particularly for arguments which are modified?

940


What is real time and near real time data warehousing?

1066


Explain the term 'tables' related to relational database management system?

975


Describe primary index in teradata?

959


What is meant by a Clique?

990


What are the updated features of teradata?

994


What is database exceptions in teradata?

897


Explain teradata architecture?

1033


Explain teradata vs. Redshift?

958


Why teradata is used?

943


What is a three-tier data warehouse?

1054


What are the frequently used data types in teradata?

1006


In BTEQ, how are the session-mode parameters being set?

1089


What are the joins in teradata and how many types of joins are there in teradata?

963