配置单元表与计数连接

时间:2019-08-19 15:17:37

标签: join hive inner-join hiveql

假定有两个表usercomments。下面是每个表中的字段,

用户

userid
username

评论

commentID
commentDescription
userid

编写查询以查找评论多于2条的用户

o / p文件

userid
username
commentDescription

1 个答案:

答案 0 :(得分:0)

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;