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 |
panzerschrank123
Starting Member
2 Posts |
Posted - 2009-08-18 : 05:04:13
|
Hello members,please can help me.One colum of my database has some varchar numbers like: 35,95 or 34,99 or 99,99 and so on.Now I want to make a statement likeselect avg(replace(cast([mycolum] as float)),',','.') from [mytable] (nolock) where [mycolum] > '0,00'But it doesn't work Pleas help me!Thanks a lot |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-08-18 : 05:25:46
|
Do the replace before casting... N 56°04'39.26"E 12°55'05.63" |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-08-18 : 05:26:45
|
try like thisdeclare @tab table(val varchar(32))insert into @tab select '35,95'insert into @tab select '34,99'insert into @tab select '99,99'select avg(cast(replace(val,',','.')as float)) from @tab |
|
|
panzerschrank123
Starting Member
2 Posts |
Posted - 2009-08-18 : 06:08:03
|
Hello Friends,It works likeSELECT avg(cast(replace([myColum],',','.')as float))from [mytable] (nolock)where [myColum] >'0' Thanks a lot ! |
|
|
|
|
|
|
|