Author |
Topic |
sapator
Constraint Violating Yak Guru
462 Posts |
Posted - 2007-09-28 : 04:08:24
|
Hi.Can you tell me what this do?Difference?replace(cast(cast(SUM(cc.NETPREMIUM/isnull(r.fixing,1)) as decimal(10,2)) as varchar) ,'.',',') as NETPREMIUMEUROANDreplace(cast(cast(SUM(cc.NETPREMIUM) as decimal(10,2)) as varchar) ,'.',',') as NETPREMIUMr is a table with currencyratesI try to figure it out. I think if the NETPREMIUM is null then it replace it with a currencyrate. Am i right? |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-09-28 : 04:12:20
|
No.In first statement NetPremium is divided by r.Fixing and the resulting output after converted to varchar, REPLACE() function replaces deimal point character with comma character.Second statement is similar to first except that NetPremium is not divided by Fixing value.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-09-28 : 04:18:34
|
"divided by r.Fixing"But rather scarily if r.Fixing IS NULL it will divide by ONE instead, which will a) silently hide the NULL value and b) I'm struggling to believe that that will be a credible value for anything, but it all depends on the data and the application of course.Lots of formatting stuff going on that would be better done in the Presentation LayerKristen |
 |
|
sapator
Constraint Violating Yak Guru
462 Posts |
Posted - 2007-09-28 : 04:21:08
|
Thank you.And the "isnull"? isnull(r.fixing,1))?the bifference between "/isnull(r.fixing,1))"and "/(r.fixing,1)" ? |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-09-28 : 04:24:37
|
"And the "isnull"? isnull(r.fixing,1))?"IsNull(A, B)returns A if it is NOT null, otherwise it returns B.Kristen |
 |
|
sapator
Constraint Violating Yak Guru
462 Posts |
Posted - 2007-09-28 : 04:25:11
|
Oh sorry you answered.So am i guessing that the second replace is most likely to be correct? |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-09-28 : 04:27:08
|
Sorry, which one is the "second replace" you are referring to? |
 |
|
sapator
Constraint Violating Yak Guru
462 Posts |
Posted - 2007-09-28 : 04:29:00
|
replace(cast(cast(SUM(cc.NETPREMIUM) as decimal(10,2)) as varchar) ,'.',',') as NETPREMIUM |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-09-28 : 04:44:14
|
quote: Originally posted by sapator replace(cast(cast(SUM(cc.NETPREMIUM) as decimal(10,2)) as varchar) ,'.',',') as NETPREMIUM
It replaces dot with commaRead about Replace function in sql server help fileMadhivananFailing to plan is Planning to fail |
 |
|
sapator
Constraint Violating Yak Guru
462 Posts |
Posted - 2007-09-28 : 04:52:28
|
Yes i ment that the whole function is most likely to be accurate because it returns the exact results. |
 |
|
|