SQL语句--分组的Top查询
时间:2014-05-19 09:12:59
收藏:0
阅读:338
代码 SELECT A.* FROM ( SELECT ROW_NUMBER() OVER(PARTITION BY Host ORDER BY Host,count(EntranceURL) DESC) AS ROW, Host, EntranceURL as PageURL ,count(EntranceURL) as EnterTimes ,sum(CASE WHEN IsBounce=1 THEN 1 ELSE 0 END ) AS BounceTimes FROM UserLoyalty GROUP BY Host,EntranceURL ) A WHERE A.ROW<=100
评论(0)