Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Other Programming Languages (http://www.programmingforums.org/forum38.html)
-   -   Transact SQL (http://www.programmingforums.org/showthread.php?t=11292)

myName Sep 11th, 2006 1:04 AM

Transact SQL
 
:

declare @a decimal

select @a = SUM(A.Amt)-SUM( B.SubAmt) 
from [UA-FAM]..FAM_Txn A Join [UA-DSM]..DSM_Txn B
        ON( A.TxnID = B.TxnID)
where A.CardID IN (SELECT CardID FROM [UA-FAM]..FAM_CardAcct WHERE FAID = 9)
AND A.Status IN(1,5)
AND MONTH(A.DateCreated) = MONTH(GETDATE())

select ISNULL(@a, 0) A


Output:
Quote:

A
----
127
Problem:
The expected result should be 126.98.
Why the output is converted to 127????:confused:

The Dark Sep 11th, 2006 10:28 AM

You could try using ISNULL(@a, 0.0), just in case ISNULL is converting the value of @a to the type of the default value.

Edit: Looking at MSDN it seems that "decimal" means zero digits to the right of the decimal point.

You might want to try chaging your definition of @a to "decimal(18,2)" or even "float".


All times are GMT -5. The time now is 1:05 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC