| Author |
Topic |
|
vmurali
Yak Posting Veteran
88 Posts |
Posted - 2007-09-17 : 03:20:02
|
| In my table I have values like (2,3). I want to get the minimum value from the column |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-09-17 : 03:42:10
|
use min() functionselect min(yourcol) from yourtable KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
vmurali
Yak Posting Veteran
88 Posts |
Posted - 2007-09-17 : 03:44:08
|
| i have values liketask2,35,48,9I need to minimum value of tasktask248 |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-09-17 : 03:46:18
|
are you using SQL Server 2005 or 2000 ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
vmurali
Yak Posting Veteran
88 Posts |
Posted - 2007-09-17 : 03:47:28
|
| SQL 2005 |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-09-17 : 03:58:44
|
[code]DECLARE @TABLE TABLE( task varchar(10))INSERT INTO @TABLESELECT '2,3' UNION ALLSELECT '5,4' UNION ALLSELECT '8,9'SELECT min_value = MIN(numberval)FROM @TABLE t CROSS apply CSVTable(task) cGROUP BY task/*min_value ----------- 2 4 8 */[/code]-- CSVTable can be obtain from http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=25830&SearchTerms=CSVTable KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
nkarthick
Starting Member
3 Posts |
Posted - 2007-09-17 : 07:48:09
|
| Hi, Try this See it ok for you :-create TABLE TestMin( Test varchar(10))INSERT INTO TestMinSELECT '2,3' UNION ALLSELECT '5,4' UNION ALLSELECT '8,9'select case when convert(int,Left(Test,charindex(',',Test) - 1)) > convert(int,Right(Test,Len(Test) - charindex(',',Test))) then Right(Test,Len(Test) - charindex(',',Test)) else Left(Test,charindex(',',Test)- 1) endfrom TestMinRegards, Narayana Karthick(VBA Developer) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-09-17 : 08:09:58
|
Narayana,this would limit to only 2 value in the csv string right ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-17 : 08:14:58
|
Who knows? The sample data only demonstrates this.OP do not tell us... E 12°55'05.25"N 56°04'39.16" |
 |
|
|
nkarthick
Starting Member
3 Posts |
Posted - 2007-09-17 : 08:23:53
|
| Khtan, Yes, my query is limited to 2 values in a column. Do u need more than that?Regards,Narayana Karthick(VBA Developer) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-09-17 : 08:28:59
|
nope. Not for me. It is up to the OP KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-09-17 : 08:29:23
|
quote: Originally posted by nkarthick Khtan, Yes, my query is limited to 2 values in a column. Do u need more than that?Regards,Narayana Karthick(VBA Developer)
There wont be any complexity in code if you follow my suggestionYou can send array of data and dont store themMadhivananFailing to plan is Planning to fail |
 |
|
|
|