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 2005 Forums
 Transact-SQL (2005)
 calculation problem

Author  Topic 

s0ftw4r32002
Starting Member

6 Posts

Posted - 2008-08-27 : 02:29:28
I use data type float on table


DECLARE @fqty float
DECLARE @fnilai float

SELECT
(fjmlawalbln +
(SELECT isnull(sum(fqty * fhpp), 0) FROM tblmmtrn_dtl where ckode = '101.011-01' and ctipe < '11') -
(SELECT isnull(sum(fqty * fhpp), 0) FROM tblmmtrn_dtl where ckode = '101.011-01' and ctipe >= '11')),
(fqtyawalbln +
(SELECT isnull(sum(fqty), 0) FROM tblmmtrn_dtl where ckode = '101.011-01' and ctipe < '11') -
(SELECT isnull(sum(fqty), 0) FROM tblmmtrn_dtl where ckode = '101.011-01' and ctipe >= '11')),
(fjmlawalbln +
(SELECT isnull(sum(fqty * fhpp), 0) FROM tblmmtrn_dtl where ckode = '101.011-01' and ctipe < '11') -
(SELECT isnull(sum(fqty * fhpp), 0) FROM tblmmtrn_dtl where ckode = '101.011-01' and ctipe >= '11'))
/(fqtyawalbln +
(SELECT isnull(sum(fqty), 0) FROM tblmmtrn_dtl where ckode = '101.011-01' and ctipe < '11') -
(SELECT isnull(sum(fqty), 0) FROM tblmmtrn_dtl where ckode = '101.011-01' and ctipe >= '11'))
from tblmmsaldo where ckode = '101.011-01' and cgendata = '0706'

set @fqty = (SELECT fqtyawalbln +
(SELECT isnull(sum(fqty), 0) FROM tblmmtrn_dtl where ckode = '101.011-01' and ctipe < '11') -
(SELECT isnull(sum(fqty), 0) FROM tblmmtrn_dtl where ckode = '101.011-01' and ctipe >= '11')
from tblmmsaldo where ckode = '101.011-01' and cgendata = '0706')

set @fnilai = (SELECT fjmlawalbln +
(SELECT isnull(sum(fqty * fhpp), 0) FROM tblmmtrn_dtl where ckode = '101.011-01' and ctipe < '11') -
(SELECT isnull(sum(fqty * fhpp), 0) FROM tblmmtrn_dtl where ckode = '101.011-01' and ctipe >= '11')
from tblmmsaldo where ckode = '101.011-01' and cgendata = '0706')

select @fnilai / @fqty
the result result : 0.40569108320691 --> not good

if i type in sql query with the query :

select 26491627.7334113/65300000
result : 0.405691083206911
the result is ok


please help me. thank you

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-27 : 02:41:05
How many times do we have to tell you that FLOAT IS APPROXIMATE?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-27 : 02:42:09
This is third consecutive thread in which you're asking the same thing. Cant you try out the solutions suggested?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-27 : 03:02:36
[code]
select count(*)
from thread
where thread_id in (109551, 109552, 109558)
and reply like '%APPROXIMATE%'
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

joe.inom
Starting Member

9 Posts

Posted - 2008-08-27 : 04:24:14
Hey , that is embarrising , if he had asked the stuff for many times , let him , until h e is clear for the fact , try to explain him.
it is like i aint got no idea on the topic ,but you see that is quite insulting to be said that " ou have asked this trice !!! "

San Diego Home Insurance

joe Alexender
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-27 : 04:27:26
quote:
Originally posted by joe.inom

Hey , that is embarrising , if he had asked the stuff for many times , let him , until h e is clear for the fact , try to explain him.
it is like i aint got no idea on the topic ,but you see that is quite insulting to be said that " ou have asked this trice !!! "

San Diego Home Insurance

joe Alexender


But we had clearly suggested the solution on previous occasions, somehow he doesnt seemed to have tried them and understood what we've suggested.
Go to Top of Page
   

- Advertisement -