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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Different calculation figure problem.

Author  Topic 

keyursoni85
Posting Yak Master

233 Posts

Posted - 2013-05-24 : 04:15:42
Hi,

I am getting diff. figures in my below equation written.


SELECT 9.36 + 9.36 / ( 284.36 ) * 15.64 = 9.8748065528 (CORRECT)
SELECT 18.72 / ( 284.36 ) * 15.64 = 1.0296131056 (INCORRECT)


I have total (9.36 * 2) Which I am putting in second select statement and gives incorrect amount.

What I am doing wrong?

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-05-24 : 05:45:52
In SQL Server arithmetic calculations follow PEDMAS/BODMAS rule... You can refer the below link for BODMAS Rule..
http://blog.sqlauthority.com/2012/09/25/sql-server-basic-calculation-and-pemdas-order-of-operation/
http://blog.sqlauthority.com/2012/04/01/sql-server-a-puzzle-illusion-confusion-april-fools-day/

Solution1:
step1: 9.36/(284.36)
step2: Step1Result * 15.64
step3: Step2Result + 9.36

Solution2:
step1: 18.72 / 284.36
step2: Step1Result * 15.64


--
Chandu
Go to Top of Page

keyursoni85
Posting Yak Master

233 Posts

Posted - 2013-05-24 : 06:29:56
Ok, fine. thanks.
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-05-24 : 06:52:07
quote:
Originally posted by keyursoni85

Ok, fine. thanks.


Welcome

--
Chandu
Go to Top of Page
   

- Advertisement -