Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Retrive highest value(its col name) from a row

Author  Topic 

Mng
Yak Posting Veteran

59 Posts

Posted - 2010-03-08 : 06:42:49
Hi, i have table with below data


A B C D HIGH
20 4 56 32
12 8 98 102
6 78 18 1
6 4 5 0


I want to update the column "HIGH" by selecting a highest value from a row with its column name. Suppose in first row, 56 is highest and its column name is "C". Similarly for 2nd row 102 is highest and its column name is "D". like this i need to update and the result is as follows.


A B C D HIGH
20 4 56 32 C
12 8 98 102 D
6 78 18 1 B
6 4 5 0 A


Can one please give a query(update query) for this.

Sachin.Nand

2937 Posts

Posted - 2010-03-08 : 06:52:55
Refer this
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=139850

PBUH
Go to Top of Page
   

- Advertisement -