[英]Hive tables join with count
假設有兩個表, user
和comments
。 以下是每個表格中的字段,
用戶 :
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.