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
 General SQL Server Forums
 New to SQL Server Programming
 formula

Author  Topic 

JJins
Yak Posting Veteran

81 Posts

Posted - 2011-11-22 : 10:43:06
does anyone have any idea how to make this statement work. Thank you.


SELECT sum ((Scottsloss2.exploss + Scottsloss2.incloss)/(scottsbook2.inforceprem )* (100))[My formula]
FROM Scottsloss2 CROSS JOIN
scottsgain2

I recieved this error.


Arithmetic overflow error converting expression to data type int.

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-11-22 : 10:47:41
SELECT sum ((1.0*Scottsloss2.exploss + Scottsloss2.incloss)/(scottsbook2.inforceprem )* (100))[My formula]
FROM Scottsloss2 CROSS JOIN
scottsgain2

SELECT sum ((convert(decimal(38,0),Scottsloss2.exploss) + Scottsloss2.incloss)/(scottsbook2.inforceprem )* (100))[My formula]
FROM Scottsloss2 CROSS JOIN
scottsgain2

You know you have a cartesian product here and will be summing every combination from both tables?
So if you have 100 rows in each table you will be summing 10000 values
10,000 rows 100,000,000 values.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-22 : 10:49:05
can i ask what you're trying to do here? why cross join? are they unrelated tables?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -