Hive如何在GROUP BY 后,获取每个GROUP的Top N

SELECT page-id, user-id, clicks  
FROM (  
    SELECT page-id, user-id, rank(page-id) as rank, clicks FROM (  
        SELECT page-id, user-id, clicks FROM mytable  
        DISTRIBUTE BY page-id  
        SORT BY page-id, clicks desc  
) a ) b  
WHERE rank < 5  
ORDER BY page-id, rank  

你可能感兴趣的:(Hive如何在GROUP BY 后,获取每个GROUP的Top N)