G
gmsft
Unregistered / Unconfirmed
GUEST, unregistred user!
SELECT Current.CompanyID AS CompanyID, Current.CompanyName AS CompanyName, Current.CompanyOrder AS ListOrder, Current.TEamount AS CurrentE, Yester.TEamount AS YesterE, Current.TIamount AS CurrentI, Yester.TIamount AS YesterI, Current.TIEamount AS CurrentIE, Yester.TIEamount AS YesterIE
FROM [SELECT CompanyID, CompanyName, CompanyOrder,
SUM(Eamount) AS TEamount, SUM(Iamount) AS TIamount, SUM(IEamount) AS TIEamount
FROM Company LEFT JOIN
(SELECT Company, Eamount, Iamount, IEamount
FROM Business WHERE Term='0509'
UNION ALL
SELECT CompanyID AS Company, 0 AS Eamount, 0 AS Iamount, 0 AS IEamount
FROM Company) AS
Business
ON Company.CompanyID=Business.Company
GROUP BY CompanyID, CompanyName, CompanyOrder]. AS [Current] LEFT JOIN [SELECT CompanyID, CompanyName, CompanyOrder,
SUM(Eamount) AS TEamount, SUM(Iamount) AS TIamount, SUM(IEamount) AS TIEamount
FROM Company
LEFT JOIN
(SELECT Company, Eamount, Iamount, IEamount
FROM Business WHERE Term='0309'
UNION ALL
SELECT CompanyID AS Company, 0 AS Eamount, 0 AS Iamount, 0 AS IEamount
FROM Company) AS
Business
ON Company.CompanyID=Business.Company
GROUP BY CompanyID, CompanyName, CompanyOrder]. AS Yester ON Current.CompanyID=Yester.CompanyID
ORDER BY Current.CompanyOrder;
ADOQuery1.SQL.Add(''
+' SELECT Current.CompanyID AS CompanyID, Current.CompanyName AS CompanyName, Current.CompanyOrder AS ListOrder, Current.TEamount AS CurrentE, Yester.TEamount AS YesterE, Current.TIamount AS CurrentI,'
+' Yester.TIamount AS YesterI, Current.TIEamount AS CurrentIE, Yester.TIEamount AS YesterIE'
+' FROM [SELECT CompanyID, CompanyName, CompanyOrder,'
+' SUM(Eamount) AS TEamount, SUM(Iamount) AS TIamount, SUM(IEamount) AS TIEamount'
+' FROM Company LEFT JOIN'
+' (SELECT Company, Eamount, Iamount, IEamount'
+' FROM Business WHERE Term=''0509'''
+' UNION ALL'
+' SELECT CompanyID AS Company, 0 AS Eamount, 0 AS Iamount, 0 AS IEamount'
+' FROM Company) AS'
+' Business'
+' ON Company.CompanyID=Business.Company'
+' GROUP BY CompanyID, CompanyName, CompanyOrder]. AS [Current] LEFT JOIN [SELECT CompanyID, CompanyName, CompanyOrder,'
+' SUM(Eamount) AS TEamount, SUM(Iamount) AS TIamount, SUM(IEamount) AS TIEamount'
+' FROM Company'
+' LEFT JOIN'
+' (SELECT Company, Eamount, Iamount, IEamount'
+' FROM Business WHERE Term=''0309'''
+' UNION ALL'
+' SELECT CompanyID AS Company, 0 AS Eamount, 0 AS Iamount, 0 AS IEamount'
+' FROM Company) AS'
+' Business'
+' ON Company.CompanyID=Business.Company'
+' GROUP BY CompanyID, CompanyName, CompanyOrder]. AS Yester ON Current.CompanyID=Yester.CompanyID'
+' ORDER BY Current.CompanyOrder');
ADOQuery1.Open;
提示:“未指定的错误”
FROM [SELECT CompanyID, CompanyName, CompanyOrder,
SUM(Eamount) AS TEamount, SUM(Iamount) AS TIamount, SUM(IEamount) AS TIEamount
FROM Company LEFT JOIN
(SELECT Company, Eamount, Iamount, IEamount
FROM Business WHERE Term='0509'
UNION ALL
SELECT CompanyID AS Company, 0 AS Eamount, 0 AS Iamount, 0 AS IEamount
FROM Company) AS
Business
ON Company.CompanyID=Business.Company
GROUP BY CompanyID, CompanyName, CompanyOrder]. AS [Current] LEFT JOIN [SELECT CompanyID, CompanyName, CompanyOrder,
SUM(Eamount) AS TEamount, SUM(Iamount) AS TIamount, SUM(IEamount) AS TIEamount
FROM Company
LEFT JOIN
(SELECT Company, Eamount, Iamount, IEamount
FROM Business WHERE Term='0309'
UNION ALL
SELECT CompanyID AS Company, 0 AS Eamount, 0 AS Iamount, 0 AS IEamount
FROM Company) AS
Business
ON Company.CompanyID=Business.Company
GROUP BY CompanyID, CompanyName, CompanyOrder]. AS Yester ON Current.CompanyID=Yester.CompanyID
ORDER BY Current.CompanyOrder;
ADOQuery1.SQL.Add(''
+' SELECT Current.CompanyID AS CompanyID, Current.CompanyName AS CompanyName, Current.CompanyOrder AS ListOrder, Current.TEamount AS CurrentE, Yester.TEamount AS YesterE, Current.TIamount AS CurrentI,'
+' Yester.TIamount AS YesterI, Current.TIEamount AS CurrentIE, Yester.TIEamount AS YesterIE'
+' FROM [SELECT CompanyID, CompanyName, CompanyOrder,'
+' SUM(Eamount) AS TEamount, SUM(Iamount) AS TIamount, SUM(IEamount) AS TIEamount'
+' FROM Company LEFT JOIN'
+' (SELECT Company, Eamount, Iamount, IEamount'
+' FROM Business WHERE Term=''0509'''
+' UNION ALL'
+' SELECT CompanyID AS Company, 0 AS Eamount, 0 AS Iamount, 0 AS IEamount'
+' FROM Company) AS'
+' Business'
+' ON Company.CompanyID=Business.Company'
+' GROUP BY CompanyID, CompanyName, CompanyOrder]. AS [Current] LEFT JOIN [SELECT CompanyID, CompanyName, CompanyOrder,'
+' SUM(Eamount) AS TEamount, SUM(Iamount) AS TIamount, SUM(IEamount) AS TIEamount'
+' FROM Company'
+' LEFT JOIN'
+' (SELECT Company, Eamount, Iamount, IEamount'
+' FROM Business WHERE Term=''0309'''
+' UNION ALL'
+' SELECT CompanyID AS Company, 0 AS Eamount, 0 AS Iamount, 0 AS IEamount'
+' FROM Company) AS'
+' Business'
+' ON Company.CompanyID=Business.Company'
+' GROUP BY CompanyID, CompanyName, CompanyOrder]. AS Yester ON Current.CompanyID=Yester.CompanyID'
+' ORDER BY Current.CompanyOrder');
ADOQuery1.Open;
提示:“未指定的错误”