日期:2014-05-17 浏览次数:20534 次
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
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