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 |
|
ConradK
Posting Yak Master
140 Posts |
Posted - 2010-08-30 : 18:06:58
|
| Okay, so I have a table with two variables. ROI, and Profit.With me so far?Okay, now it gets tricky.If the ROI is .24 or more then it doesn't matter what the value forthe profit is. Likewise, if profit is 3.22 or more, it doesn't matter what the ROI is. So those are the bounds of the math.Now, if a ROI is something like .12, then the Profit value MUST be at least 1.66 or more, get it?If the ROI is .08, then the Profit must be 1.07 or more...I'm sure this is calculus, but my lexicon is insufficient to google the problem.... |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2010-08-30 : 20:13:58
|
| you can easily setup a computed column for this.. and also use the persisted computed columns for better performance.. open up books online and look for persisted computed columns for more info..Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-08-30 : 23:01:12
|
| sounds more like check constraint to me...not sure what OP is after.do you have two columns representing ROI and Profit respectively? |
 |
|
|
ConradK
Posting Yak Master
140 Posts |
Posted - 2010-08-31 : 09:39:59
|
| yes, I have two columns that do thatSo this is what I got:declare @roiline floatdeclare @profitline floatset @roiline = .22set @profitline = 3.22select itemroitrue,ItemNumber,PureProfitCoef,itemroitrue*Cost as "profit",(((select AVG(itemroitrue*cost)/AVG(itemroitrue) from ordersheet)*itemroitrue*(@profitline/((select AVG(itemroitrue*cost)/AVG(itemroitrue) from ordersheet)*@roiline)))+(itemroitrue*Cost)) - (@profitline*2) as "NewtonNumber" from ordersheetorder by NewtonNumber descand then anywhere the newtonnumber is 3.22 or greater |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-08-31 : 09:51:09
|
| what is the exact formula to determine the roi/profit rules? |
 |
|
|
ConradK
Posting Yak Master
140 Posts |
Posted - 2010-08-31 : 10:22:41
|
| I guess I'm not sure how that is relevent to the problem at hand. It shouldn't be '-(@profitline*2)' it should just be '(@profitline)' by the way, and anywhere the newtonnumber is greater than 0 |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-08-31 : 11:14:36
|
| i guess i don't understand what the problem at hand is...i thought you are trying to enforce a rule |
 |
|
|
|
|
|
|
|