SQL Server 2000 SP3
Need to join tables A & B, so I can add the $BudgetAmt column from Table B to Table A.
Desired resulting record set:
A.GLAcctNo, A.$NetChgBal, A.Year, A.Period, B.$BudgetAmt
Table A [ GL net chg balances by GL Acct No ] Fields: GL Acct No |$net chg Bal | Year | period Table B
[GL budget by GL Acct No]
Fields: GL Acct No |$Budget Amt | BudgetID | periodMy
challenge is, how to join the tables and get the BudgetID from table B to pair with the Year in table A.?In table A,
the values for YEAR are 2011, 2010, 2009In table B, the
values for BudgetID are "BUD2011","Bud2010","Bud2009"BudgetID 2011 should match up with YEAR 2011, BudgetID 2010 should match up with YEAR 2010, etc..
Certainly will join on GL Acct No, however, I need to match up the BudgetID in table B with the YEAR in table A to make record set join correctly.What is the method/syntax for joining two tables based upon matching up values in columns?
=========================================================
select a.GLACCT,a.$netchg,a.year,a.period,b.budgetAmt
from TableA a
inner join TableB b
on a.GLAcct = b.GLAcct
and ?????
How to say grab B.BudgetAmt value, where a.year = 2011 and b.budgetID = "bud2011"
and also grab b.BudgetAmt where a.year = 2010 and b.BudgetID = "Bud2010"
Appreciate your input.
Thanks,Andrew
Need to join tables A & B, so I can add the $BudgetAmt column from Table B to Table A.
Desired resulting record set:
A.GLAcctNo, A.$NetChgBal, A.Year, A.Period, B.$BudgetAmt
Table A [ GL net chg balances by GL Acct No ] Fields: GL Acct No |$net chg Bal | Year | period Table B
[GL budget by GL Acct No]
Fields: GL Acct No |$Budget Amt | BudgetID | periodMy
challenge is, how to join the tables and get the BudgetID from table B to pair with the Year in table A.?In table A,
the values for YEAR are 2011, 2010, 2009In table B, the
values for BudgetID are "BUD2011","Bud2010","Bud2009"BudgetID 2011 should match up with YEAR 2011, BudgetID 2010 should match up with YEAR 2010, etc..
Certainly will join on GL Acct No, however, I need to match up the BudgetID in table B with the YEAR in table A to make record set join correctly.What is the method/syntax for joining two tables based upon matching up values in columns?
=========================================================
select a.GLACCT,a.$netchg,a.year,a.period,b.budgetAmt
from TableA a
inner join TableB b
on a.GLAcct = b.GLAcct
and ?????
How to say grab B.BudgetAmt value, where a.year = 2011 and b.budgetID = "bud2011"
and also grab b.BudgetAmt where a.year = 2010 and b.BudgetID = "Bud2010"
Appreciate your input.
Thanks,Andrew