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 |
X002548
Not Just a Number
15586 Posts |
Posted - 2007-07-09 : 09:42:40
|
I gotta search the site more but, and this is a presentation issue, and I may need to convince people of this, BUTIf I haveRent and Tax, and they want to accrue the tax over years, kind of likeYear 1 2.50 + (2.50 * .04)Year 2 2.50 + ((2.50 * .04)*.04)Year 3 2.50 + (((2.50 * .04)*.04)*.04)ectThis is what I've come up with so far, but it's not even closebtw, does the above even make sense? They are doing it this way in Excels sheets right now.CREATE TABLE #temp(Rent money, [Year] int, Tax decimal(12,4))GOINSERT INTO #temp(Rent, [Year], Tax)SELECT 25, 1, .1 UNION ALLSELECT 25, 2, .1 UNION ALLSELECT 25, 3, .1 UNION ALLSELECT 25, 4, .1GOSELECT * FROM #tempSELECT a.[Year], ((b.Rent + b.Rent*b.Tax)*a.Tax) AS Rent_Tax, b.[Year] - 1 AS PriorYear,b.*FROM #temp a LEFT JOIN #temp b ON a.[Year] = b.[Year] - 1GODROP TABLE #tempGO Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-07-09 : 09:45:22
|
Where is the SQLTeam front-end presentation expert ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
X002548
Not Just a Number
15586 Posts |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-07-09 : 10:29:47
|
how about a UDF that returns the product of tax with no of years as input ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
X002548
Not Just a Number
15586 Posts |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2007-07-09 : 11:06:10
|
Is this what you're looking for?SELECT *, RENT + RENT* POWER(TAX +1,[YEAR]) from @tbl Jim |
 |
|
X002548
Not Just a Number
15586 Posts |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-07-10 : 09:36:23
|
yes it is.economics 101 lesson 2 _______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
X002548
Not Just a Number
15586 Posts |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-07-10 : 10:16:50
|
didn't jimf give it to you?_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
X002548
Not Just a Number
15586 Posts |
Posted - 2007-07-10 : 10:54:42
|
Yeah, I guess he did, but I had to worry about year 1CREATE TABLE #temp(Tax money, [Year] int, TaxInc decimal(12,2))GOINSERT INTO #temp(Tax, [Year], TaxInc)SELECT 2.5, 1, 4 UNION ALLSELECT 2.5, 2, 4 UNION ALLSELECT 2.5, 3, 4 UNION ALLSELECT 2.5, 4, 4 UNION ALLSELECT 2.5, 5, 4 UNION ALLSELECT 2.5, 6, 4 UNION ALLSELECT 2.5, 7, 4 UNION ALLSELECT 2.5, 8, 4 UNION ALLSELECT 2.5, 9, 4 UNION ALLSELECT 2.5, 10, 4 UNION ALLSELECT 2.5, 11, 4 UNION ALLSELECT 2.5, 12, 4 UNION ALLSELECT 2.5, 13, 4 UNION ALLSELECT 2.5, 14, 4 UNION ALLSELECT 2.5, 15, 4 UNION ALLSELECT 2.5, 16, 4 UNION ALLSELECT 2.5, 17, 4 UNION ALLSELECT 2.5, 18, 4 UNION ALLSELECT 2.5, 19, 4 UNION ALLSELECT 2.5, 20, 4GO SELECT [Year], Tax FROM #Temp WHERE [Year] = 1UNION ALL SELECT [Year]+1, CONVERT(decimal(19,2),Tax*POWER(1+(TaxInc/100),[Year])) AS Taxes FROM #temp WHERE [Year] < 20 Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
|
|
|
|