簡體   English   中英

配置單元表與計數連接

[英]Hive tables join with count

假設有兩個表, usercomments 以下是每個表格中的字段,

用戶

userid
username

評論

commentID
commentDescription
userid

編寫查詢以查找評論多於2個的用戶

o / p文件

userid
username
commentDescription
select u.userid,
       u.username,
       c.commentDescription 
  from user u
       inner join (select c.userid, c.commentDescription, 
                          count(*) over(partition by userid) cnt
                     from comments c
                  ) c 
        on u.userid=c.userid and c.cnt>2; 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM