Showing posts with label scored. Show all posts
Showing posts with label scored. Show all posts

Wednesday, March 21, 2012

Find the greatest of three columns per each row and display

Hi,

i have a problem where in i have to display the greatest marks scored by each student.

How can i do this? Is there any built in TSQL function.

Rgds..,

Aazad

You either use a CASE Statement or Pivot the data to make a relational query possible through the aggregation functions.

SELECT CASE WHEN COlA > COLB THEN COLA ELSE

(CASE WHEN COLB > COLC THEN COLB ELSE COLC END)

END

FROM SomeTable

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

|||

Hi,

I worked. Nice one. I got the other way too..!

Rgds..,

Aazad.