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.
| Author |
Topic |
|
baze7
Yak Posting Veteran
58 Posts |
Posted - 2010-04-05 : 17:09:51
|
| Not sure if anyone can help, but I cannot get this sum to work properly:sum ((ivn.price * ivn.qty_invoiced) - ((ivn.price * (ivn.qty_invoiced) * ivn.disc / 100))) / ((ivn.price * ivn.qty_invoiced) - (((ivn.price * (ivn.qty_invoiced) * ivn.disc / 100))) - (item.unit_cost * ivn.qty_invoiced))If I do this:sum ((ivn.price * ivn.qty_invoiced) - ((ivn.price * (ivn.qty_invoiced) * ivn.disc / 100)))it is correct. If I do sum((ivn.price * ivn.qty_invoiced) - (((ivn.price * (ivn.qty_invoiced) * ivn.disc / 100))) - (item.unit_cost * ivn.qty_invoiced))it is fine, just putting the 2 together is the issue.ThanksChad |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-04-05 : 18:15:38
|
| Are you sure you should be using SUM()? Perhaps you could explain what you have (table structure and sample data), and what you're trying to achieve.There are 10 types of people in the world, those that understand binary, and those that don't. |
 |
|
|
Asken
Starting Member
38 Posts |
Posted - 2010-04-07 : 05:23:07
|
| Divide by 100.0 instead of just 100...A bit short maybe...SELECT 1 / 100 = 0 -- integer divisionSELECT 1 / 100.0 = 0.010000Reporting & Analysis Specialist |
 |
|
|
|
|
|