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 |
|
jung1975
Aged Yak Warrior
503 Posts |
Posted - 2006-03-28 : 18:56:53
|
| I am trying to use CTE to get both YTDrevenue and MTD revenue. my question is how I can join YTDrevenue and MTDrevenue to get YTDrevenue.payments and MTDrevenue.payments?with YTDrevenueAS( select sum(payments)as payments from revenue_aggregate a join Revenue_aggregate_assertions b on a.[month] = b.[month] and a.[year] = b.[year] and a.[Unit_abbr] = b.[Unit_abbr] and a.financial_class_code = b.financial_class_codeWHERE ((a.[month] <= 12) AND (a.[year] = 2005) AND (a.[unit_abbr] = 'AA'))),MTDrevenueAS(select sum(payments)as payments from revenue_aggregate a join Revenue_aggregate_assertions b on a.[month] = b.[month] and a.[year] = b.[year] and a.[Unit_abbr] = b.[Unit_abbr] and a.financial_class_code = b.financial_class_codeWHERE ((a.[month] = 12) AND (a.[year] = 2005) AND (a.[unit_abbr] = 'AA')))select YTDrevenue.payments,MTDrevenue.paymentsfrom MTDrevenue join YTD revenue |
|
|
|
|
|