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 |
mxfrail
Yak Posting Veteran
84 Posts |
Posted - 2009-09-03 : 11:41:33
|
[code]CREATE FUNCTION ASP_MailingValue( @ClientID int, @ProdDate datetime)RETURNS decimalASBEGIN RETURN ( SELECT Sum(tblContractDetail.[BillingFlatFee]+tblContractDetail.[billingrate]*tblContractDetail.[homes]/1000) AS [Value] FROM (tblContractDetail INNER JOIN tblContracts ON tblContractDetail.ContractID = tblContracts.ContractID) WHERE tblContracts.clientid= @ClientID and tblContractDetail.ProdDate = @ProdDate )END[/code]In the above ... if BillingRate = 25 and BillingFlatFee=0 and Homes=16500 it should be 412.5 but is returning 413.Any help?Thanks |
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2009-09-03 : 11:46:05
|
You need to give the decimal a precision.So, decimal(6,2) or similar, rather than just decimal.You also need to ensure your other fields are decimals, you may wannt to ensure this by CASTing or CONVERTing each field. |
|
|
mxfrail
Yak Posting Veteran
84 Posts |
Posted - 2009-09-03 : 11:50:24
|
Ahh ... perfect. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|