日期:2014-05-18 浏览次数:20737 次
SELECT [name], AVG(a) as a, SUM(CASE WHEN b<=5 THEN 1 ELSE 0 END) * 100.0 / COUNT(b) AS b FROM ta GROUP BY name having AVG(a)>'1' UNION ALL SELECT '统计', AVG(a) as a, AVG(b) as b FROM( SELECT [name], AVG(a) as a, SUM(CASE WHEN b<=5 THEN 1 ELSE 0 END) * 100.0 / COUNT(b) AS b FROM ta GROUP BY name having AVG(a)>'1' )ta
select * from ta where name in ( SELECT [name] FROM ta GROUP BY name having AVG(a)>1 )