| Author |
Topic |
|
vishu.av
Starting Member
26 Posts |
Posted - 2007-04-24 : 02:32:31
|
| Hi All,Is there any equivalent of GREATEST(something) and LEAST(something)in SQL server 2000Thanks in advance.vishuBangalore |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-24 : 03:08:07
|
| MAX and MIN.Peter LarssonHelsingborg, Sweden |
 |
|
|
vishu.av
Starting Member
26 Posts |
Posted - 2007-04-24 : 04:33:01
|
| Hi Peter,Thanks for the response.Infact i have more than 1 value in my list.I mean i have to select the largest of values from a group or list which contain one value as a column name and other as some integer values.GREATEST( a,b,c..) and 'a' being a column of a table with numeric value.vishuBangalore |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-04-24 : 04:38:59
|
I knew it was not that simple!Something like this?select max(a), min(a) from(Select max(a) as a from tableunion allselect <b> -- <b> represents some numeric value hereunion allselect <c> -- <c> represents some numeric value here) temp Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-24 : 04:47:08
|
<b> and <c> are from what table Peter LarssonHelsingborg, Sweden |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-24 : 04:48:27
|
| select max(value), min(value) from(Select a as value from tableunion allselect b from tableunion allselect c from table) as tPeter LarssonHelsingborg, Sweden |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-04-24 : 04:50:09
|
quote: Originally posted by Peso <b> and <c> are from what table Peter LarssonHelsingborg, Sweden
That's why I put the comments..they are not from the table, those are numeric literals.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-24 : 04:54:21
|
| Ahh, I see.Is MAX(a) equal to MIN(a), when first calculating MAX(a) AS a in derived table?Peter LarssonHelsingborg, Sweden |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-04-24 : 04:57:25
|
quote: Originally posted by Peso Ahh, I see.Is MAX(a) equal to MIN(a), when first calculating MAX(a) AS a in derived table?Peter LarssonHelsingborg, Sweden
Oh..I see the error there...Initially I was just thinking about max value there.select max(a), min(a) from(Select a as a from tableunion allselect <b> -- <b> represents some numeric value hereunion allselect <c> -- <c> represents some numeric value here) temp Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
vishu.av
Starting Member
26 Posts |
Posted - 2007-04-24 : 06:04:15
|
| Thanks for the replyvishuBangalore |
 |
|
|
|