Select查询

指定列

select * from dealer_leads;
select leads_id,dealer_id,create_time from dealer_leads;
select e.leads_id from dealer_leads e;

函数列

可以使用hive自带的函数,也可以是用户自定义的函数

select companyid,upper(host),UUID(32) from dealer_action_log;

upper()是hive自带函数;UUID()是用户自定义函数

算数运算列

select companyid,userid,(companyid+userid) as sumint from dealer_action_log;

限制返回条数

select * from dealer_action_log limit 100;

Case When Then

select case companyid when 0 then '未登录' else companyid end from dealer_action_log;
select case when companyid=0 then '未登录' else companyid end from dealer_action_log;

子查询

Hive对子查询支持有限,只允许在select from后面出现

select * from (
select dealerid,dealername from dealer_info i where i.dealerid='10595'
) a;

results matching ""

    No results matching ""