January 29, 2009 at 7:39 pm
Can someone explain how this works.
(isnull(([UnitPrice]*((1.0)-[UnitPriceDiscount]))*[OrderQty],(0.0)))
If the UnitPrice is 10.00 and the OrderQty is 4 how does this equation play out?
What is the 1.0 for ?
thank a lot !
Dam again!
January 29, 2009 at 10:11 pm
The 1.0 is to implicity force the calculation to a FLOAT datatype if everything turns out to be an INTEGER. The rest is a matter of simple substitution and following algebraic hierarchy rules.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 29, 2009 at 10:19 pm
Thanks,
Is the UnitPriceDiscount a percentage or a number ?
select 10 *((1.0)-4)* 6
or
select 10 *((1.0)-.25)* 6
Dam again!
January 29, 2009 at 10:22 pm
Looking at the formula, I don't think it is an integer. Best way to find out is look at the data in the table.
January 29, 2009 at 10:53 pm
AFCC Inc. Com (1/29/2009)
Thanks,Is the UnitPriceDiscount a percentage or a number ?
select 10 *((1.0)-4)* 6
or
select 10 *((1.0)-.25)* 6
Heh... you tell us... you're the one that can see the table. 🙂
--Jeff Moden
Change is inevitable... Change for the better is not.
January 30, 2009 at 10:40 am
I do not have any data in the table yet.
I see what you're saying.
I have found some info on working with percentages from
So what I can tell from my first question is that the [UnitPriceDiscount] is a subtraction amount from the unit price.
--Subtract Half of the unit price from the unit price
select cast(10.40 *((1.0)-.50)* 1 as money)
--Add half of the unit price to the unit price
select cast(10.40 /((1.0)-.50)* 1 as money)
Dam again!
January 30, 2009 at 12:24 pm
Correct... and a 30% discount rate would mean you only pay 70% of the unit price and that's the other reason for the 1... you subtract 30% (0.3) from 1 (100%) to get the 70% to pay...
select cast(10.40 *((1.0)-.30)* 1 as money)
--Jeff Moden
Change is inevitable... Change for the better is not.
February 3, 2009 at 3:09 pm
Thanks for the help...
Dam again!
February 4, 2009 at 8:18 pm
You bet... thank you for the feedback.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply