hive 使用总结

hive select count 使用distinct 去重

select count(distinct name) from log where day=20160920;
已邀请:

wenda

赞同来自:

hive like 查询

语法:
A LIKE B
操作类型:
strings
描述:
如果字符串A或者字符串B为NULL,则返回NULL;
如果字符串A符合表达式B 的正则语法,则为TRUE,否则为FALSE。
B中字符”_”表示任意单个字符 ,字符”%”表示任意数量的字符。

select * from targeting.orc where dt=20161105 and profile like '%33367%' limit 10;

wenda

赞同来自:

hive group by 分组统计

select ch ,count(1) as num from TabOrder group by ch;

wenda

赞同来自:

left semi join 用法 hive 查询左表中数据 哪些在右表中


select count(*) from 
(select A.token, A.pkg_name from
(select col['token'] token, col['pkg_name'] pkg_name from log where day=20170724 and col['ac']=60) A
) B
left semi join
(select C.token, C.pkg_name from
(select col['token'] token, col['pkg_name'] pkg_name from log where day=20170724 and col['ac']=50) C
) D
on B.token=D.token and B.pkg_name=D.pkg_name


也可以在on 后面加上group by 分组查看

wenda

赞同来自:

查看hive表的建表语句

 show create table anti_fraud.other_billing_view; 

要回复问题请先登录注册

www.000webhost.com