select expr2, sum(expr3)
from
(SELECT address AS Expr1, MAX(DISTINCT STAGE) AS Expr2, 
      MAX(DISTINCT REVENUE) AS Expr3
FROM report
WHERE (CREATOR = 'bj40')
GROUP BY address ) as A
group by expr2

解决方案 »

  1.   

    SELECT address AS Expr1, MAX(DISTINCT STAGE) AS Expr2, 
          MAX(DISTINCT REVENUE) AS Expr3
    into #temp FROM report
    WHERE (CREATOR = 'bj40')
    GROUP BY address
    go
    select Expr2,sum(Expr3) from #temp
    go
    drop table #temp
      

  2.   

    错了!这个
    SELECT address AS Expr1, MAX(DISTINCT STAGE) AS Expr2, 
          MAX(DISTINCT REVENUE) AS Expr3
    into #temp FROM report
    WHERE (CREATOR = 'bj40')
    GROUP BY address
    go
    select Expr2,sum(Expr3) from #temp group by Expr2
    go
    drop table #temp