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

sel
studentid,
studentname,
case
when subject1>subject2 and subject1>subject3
then subject1
when subject2>subject1 and subject2>subject3
then subject2
when subject3>subject1 and subject3>subject2
then subject3
end as high_score,
case
when high_score = subject1
then 'subject1'
when high_score = subject2
then 'subject2'
when high_score = subject3
then 'subject3'
end as subject_name
from stud1
order by 1,2
;

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain vproc in teradata?

1012


What is node? How many nodes and amps used in your previous project?

1113


What is meant by a dispatcher?

1026


What is the meaning of Caching in Teradata?

1143


Why does varchar occupy 2 extra bytes?

1203


How many tables can you join in v2r5?

1077


How to identify ppi columns?

1188


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

988


Can we have an unconnected lkp to lookup a db2 record against a teradata record? Doesnt seem to work. I could be wrong

1085


What is the purpose of upsert command?

1183


What exactly do you know about catching in teradata?

1042


If the PMON is not working then how do you identify and monitor all the processes, resources and sessions ?

2207


What is spool space? Why do you get spool space errors?

1029


What are the steps to create a data model?

1065


What is the use of having index on table?

1007