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 |
|
mvanwyk
Yak Posting Veteran
99 Posts |
Posted - 2009-09-16 : 07:05:21
|
| Hi Team.I have 18 SAP databases.The customer would like to see a cross section of income and expense across all 18 companies.Each company has its own SAP db.For example:SBO_CompanyOneSBO_CompanyTwoIncome table = INV1Expense table = PCH1So far I have this.SELECT 'Company One' AS Company, SUM(TotalSumSy) AS Customers,(SELECT SUM(TotalSumSy) AS Expr1 FROM SBO_CompanyOne.dbo.PCH1WHERE (LineStatus <> 'C')) AS SuppliersFROM SBO_CompanyOne.dbo.INV1WHERE (LineStatus <> 'C')This gives me the following.Company Customer SuppliersCompany One 4162598.680000 2874958.470000But how do I create a dataset that results in something that looks like this.Company Customer SuppliersCompany One 4162598.680000 2874958.470000Company Two 1920729.250000 2375304.100000Any help would be appreciated. |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2009-09-16 : 07:36:59
|
| SELECT 'Company One' AS Company, SUM(TotalSumSy) AS Customers,(SELECT SUM(TotalSumSy) AS Expr1 FROM SBO_CompanyOne.dbo.PCH1WHERE (LineStatus <> 'C')) AS SuppliersFROM SBO_CompanyOne.dbo.INV1WHERE (LineStatus <> 'C')UNION ALLSELECT 'Company One' AS Company, SUM(TotalSumSy) AS Customers,(SELECT SUM(TotalSumSy) AS Expr1 FROM SBO_CompanyTwo.dbo.PCH1WHERE (LineStatus <> 'C')) AS SuppliersFROM SBO_CompanyTwo.dbo.INV1WHERE (LineStatus <> 'C')- Lumbago |
 |
|
|
mvanwyk
Yak Posting Veteran
99 Posts |
Posted - 2009-09-16 : 07:47:38
|
| Thanks Lumbago...learn something new everyday |
 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2009-09-16 : 08:01:25
|
- Lumbago |
 |
|
|
|
|
|