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 |
|
Ex
Posting Yak Master
166 Posts |
Posted - 2005-01-06 : 19:02:10
|
| Hey allthanks to spirit1from one of my previous posts i got this forumal to Multipliy all the values in the col of a tableSELECT CAST(ROUND(COALESCE(EXP(SUM(LOG(ABS(nullif(columnName,0))))),0),0) AS INTEGER) FROM mytable where ....the problem is the nullif method if i had the col values505answer would be = 25 and not 0 like it should bei need to do it in a formula as the rest will be used in a updateUPDATE aTable SET aCol= /*Multiplication*/WHERE etc......any ideas? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-01-17 : 06:02:48
|
Try thisDeclare @t table(no numeric)insert into @t values(1)insert into @t values(2)insert into @t values(0)insert into @t values(4)insert into @t values(5)declare @n numericset @n=1select @n=@n * (Select case when T.no=0 then 1 else T.no end from @t where no=T.No) from @t Tselect @n Madhivanan |
 |
|
|
RM
Yak Posting Veteran
65 Posts |
Posted - 2005-01-17 : 06:56:02
|
| Just a small change...Declare @t table(num numeric)insert into @t values(5)insert into @t values(0)insert into @t values(5)declare @n numericset @n=1select @n=@n * (case when isnull(T.num,0)=0 then 1 else T.num end) from @t Tselect @n--OR--SELECT CAST(ROUND(COALESCE(EXP(SUM(LOG(ABS(case when isnull(num,0)=0 then 1 else num end)))),0),0) AS INTEGER) from @t T |
 |
|
|
|
|
|