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.
| Author |
Topic |
|
detlion1643
Yak Posting Veteran
67 Posts |
Posted - 2010-05-28 : 10:17:02
|
| I am looking for a way to find the lowest value in a list of 6 values. Lets say I am looking to do something like this: MIN(3,4,1,8,2,9), it should return 1. But since MIN only works for a column, I'm not sure what else could be used. |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-05-28 : 10:34:07
|
| You can use row_number() function for the same.Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-05-28 : 10:34:49
|
quote: Originally posted by detlion1643 I am looking for a way to find the lowest value in a list of 6 values. Lets say I am looking to do something like this: MIN(3,4,1,8,2,9), it should return 1. But since MIN only works for a column, I'm not sure what else could be used.
Can you explain with some sample data from your tables and expected output? |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2010-05-28 : 10:35:28
|
| use visakhs function ParseValues. It will return a column that you can take a min onSELECT MIN(f.Val)FROM Table tCROSS APPLY dbo.ParseValues(t.field,'_')fGROUP BY t.Fieldhttp://visakhm.blogspot.com/2010/02/parsing-delimited-string.htmlJimEveryday I learn something that somebody else already knew |
 |
|
|
detlion1643
Yak Posting Veteran
67 Posts |
Posted - 2010-05-28 : 10:45:59
|
| Thanks jimf!Changed a little bit up to fit my needs, but works nonetheless! |
 |
|
|
|
|
|
|
|