Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
consider this is my table:-


id age SALARY
20 77 30000
10 8 50000
30 9 20000


have to find out without using column name because we don't know in which column contains the largest value
here I want know in first row which value is greatest ?
how can I find out the maximum value in particular row?

pls help meee
Posted
Updated 8-Jul-15 0:19am
v2

1 solution

If you mean the "second greatest" value, then try:
SQL
WITH myTableWithRows AS (
    SELECT (ROW_NUMBER() OVER (ORDER BY myTable.Salary DESC)) as row,*
    FROM myTable)
SELECT * FROM myTableWithRows WHERE row = 2
 
Share this answer
 
v2
Comments
[no name] 8-Jul-15 6:08am    
not second. Have to find out the greatest value. my table have 33 columns and 6000 rows.in fist row which is the maximum value? like dat
[no name] 8-Jul-15 6:10am    
and we don't know which column consist that value so with out using column name we have to find out the maximum value in a particular row
OriginalGriff 8-Jul-15 6:26am    
Without the column names? I can't think of any way you can do that: even a PIVOT needs the columns on which it is to work.
[no name] 8-Jul-15 6:43am    
uff..that I don't know..i am fed up with these is there any way? I want to find out 1000 row's greatest value..hw can we select the column if we using column name?
OriginalGriff 8-Jul-15 7:13am    
You can find out the max value in a row, if you use the column names:
http://stackoverflow.com/questions/71022/sql-max-of-multiple-columns
Presents several ways to do it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900