Wednesday, March 28, 2012

help! substract two columns from two tables

I hope you can understand what I mean !
my english is not very good , i live in taiwan! i have a problem
table A :(income of year 2004) table B: (income of year 2003)
ITEM NAME INCOME INCOME growth
_______________________________________________
A 1000 500 -500
B 2000 2500 500
C 3000 1000 -200
How do I get then value "growth" , table A and table B are from
diferent datasource , if you know , please help me!! thank you very much!sorry ! growth of the third line(ITEM NAME = C) IS -2000
"Kline" wrote:
> I hope you can understand what I mean !
> my english is not very good , i live in taiwan! i have a problem
> table A :(income of year 2004) table B: (income of year 2003)
> ITEM NAME INCOME INCOME growth
> _______________________________________________
> A 1000 500 -500
> B 2000 2500 500
> C 3000 1000 -200
> How do I get then value "growth" , table A and table B are from
> diferent datasource , if you know , please help me!! thank you very much!|||Hello! Chris , your answer is helpful to me !! thanks a lot!
"Chris McGuigan" wrote:
> Kline,
> If by 'Table' you mean a Reporting Services Table, then you can't refer to
> items from different tables like that. Data regions in RS can only reference
> one dataset.
> When you say 'datasources' I am assuming you mean data on different servers.
> If so in MS SQL Server you can create "Linked Servers" to any OLE DB
> compliant datasource.
> If it's merely different databases on the same server, you just prefix the
> table name with the database and owner name, for example
> db2004.dbo.IncomeTable.
> The trick is to make one RS dataset pull the data from all the 'physical'
> datasources. Then you will have access to all your fields in one table.
> Your query may look something like this;
> SELECT A.Item as Item, A.Income as Income2004, B.Income as Income2003,
> B.Income - A.Income as Growth
> FROM ServerA.DB2004.dbo.IncomeTable as A
> JOIN ServerB.DB2003.dbo.IncomeTable as B
> You need to get all the data in one query and hence one RS table.
> Hope that helps.
> Chris McGuigan
> "Kline" wrote:
> > sorry ! growth of the third line(ITEM NAME = C) IS -2000
> >
> > "Kline" wrote:
> >
> > > I hope you can understand what I mean !
> > > my english is not very good , i live in taiwan! i have a problem
> > >
> > > table A :(income of year 2004) table B: (income of year 2003)
> > > ITEM NAME INCOME INCOME growth
> > > _______________________________________________
> > > A 1000 500 -500
> > > B 2000 2500 500
> > > C 3000 1000 -200
> > >
> > > How do I get then value "growth" , table A and table B are from
> > > diferent datasource , if you know , please help me!! thank you very much!

No comments:

Post a Comment