不知道你要查什么,你看看是不是你想要的SELECT Accounts , erjidaili , o.ticheng2 , Expr1 , fandian2 FROM ( SELECT a.Accounts , a.erjidaili , --o.ticheng2 , o.Accounts AS Expr1 , SUM(o.ticheng2) AS fandian2 FROM QPTreasureDB.dbo.OnLineOrder o , QPAccountsDB.dbo.AccountsInfo a WHERE o.OrderStatus = '2' AND o.Accounts = a.Accounts AND a.erjidaili = 'test100' GROUP BY a.Accounts , a.erjidaili , --o.ticheng2 , o.Accounts ) a INNER JOIN QPTreasureDB.dbo.OnLineOrder o ON o.Accounts = a.Accounts
select a.Accounts, a.erjidaili,o.Accounts AS Expr1, SUM(o.ticheng2) AS fandian2 from QPTreasureDB.dbo.OnLineOrder o,QPAccountsDB.dbo.AccountsInfo a where o.OrderStatus='2' and o.Accounts=a.Accounts and a.erjidaili='test100' GROUP BY a.Accounts, a.erjidaili, o.Accounts
erjidaili ,
o.ticheng2 ,
Expr1 ,
fandian2
FROM ( SELECT a.Accounts ,
a.erjidaili ,
--o.ticheng2 ,
o.Accounts AS Expr1 ,
SUM(o.ticheng2) AS fandian2
FROM QPTreasureDB.dbo.OnLineOrder o ,
QPAccountsDB.dbo.AccountsInfo a
WHERE o.OrderStatus = '2'
AND o.Accounts = a.Accounts
AND a.erjidaili = 'test100'
GROUP BY a.Accounts ,
a.erjidaili ,
--o.ticheng2 ,
o.Accounts
) a
INNER JOIN QPTreasureDB.dbo.OnLineOrder o ON o.Accounts = a.Accounts
from QPTreasureDB.dbo.OnLineOrder o,QPAccountsDB.dbo.AccountsInfo a
where o.OrderStatus='2' and o.Accounts=a.Accounts and a.erjidaili='test100'
GROUP BY a.Accounts, a.erjidaili, o.Accounts