码迷,mamicode.com
首页 > 数据库 > 详细

SQL语句--分组的Top查询

时间:2014-05-19 09:12:59      阅读:338      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   class   code   c   

bubuko.com,布布扣
代码

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
bubuko.com,布布扣

 

SQL语句--分组的Top查询,布布扣,bubuko.com

SQL语句--分组的Top查询

标签:des   style   blog   class   code   c   

原文地址:http://www.cnblogs.com/swtool/p/3731982.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!