Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 11th, 2006, 12:04 AM   #1
myName
Programmer
 
Join Date: Oct 2005
Posts: 48
Rep Power: 0 myName is on a distinguished road
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????
myName is offline   Reply With Quote
Old Sep 11th, 2006, 9:28 AM   #2
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 852
Rep Power: 4 The Dark is on a distinguished road
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".
The Dark is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:29 PM.

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