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 |
|
diabolic
Starting Member
4 Posts |
Posted - 2007-07-17 : 11:15:48
|
| Hi all,i'm new to SQL but i've been asked to write an SQL statement to select the latest numeric version value(in this case version 3) from this table, any help? Name Version Episode John 4c 60 John 4b 50 John 4a 40 John 3 30 John 2 20 John 1 10Regards |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-07-17 : 11:17:18
|
[code]SELECT MAX(Version)FROM this_tableWHERE isnumeric(Version) = 1[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
diabolic
Starting Member
4 Posts |
Posted - 2007-07-17 : 11:22:14
|
| Thanks Khtan for your quick reply,is the where isnumeric (version)=1 switch to check if the value is numeric and take the max, and is it set to one which means ON?so if the table name is Johndocs the statement will be SELECT MAX Version from Johndocs WHERE isnumeric Version=1is that right?Thanks |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-07-17 : 11:40:26
|
SELECT MAX(Version)FROM this_tableWHERE Version NOT LIKE '%[^0-9]%'Just in case there is a version 4e Peter LarssonHelsingborg, Sweden |
 |
|
|
diabolic
Starting Member
4 Posts |
Posted - 2007-07-17 : 11:44:16
|
| Thanks Peter,i want to select only numeric value, so only 3 i don't want to select 4a or 4b but only versions with only numbers. Is that what u meant?Regards |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-07-17 : 12:22:20
|
| No. 4e can be treated as a numeric value with the ISNUMERIC function.Peter LarssonHelsingborg, Sweden |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-18 : 03:38:39
|
| Isnumeric is not reliableSelect data from(select ' 943 ' as dataunion allselect '345'union allselect '$345,456'union allselect '12d2') Twhere isnumeric(data)=1MadhivananFailing to plan is Planning to fail |
 |
|
|
diabolic
Starting Member
4 Posts |
Posted - 2007-07-18 : 05:00:16
|
| Thanks Mad but can i understand how is your statement working? |
 |
|
|
|
|
|