复习一下。
P107 函数列表
group by 生成分组之后,可以直接加 having 再进行过滤
order by 全局排序,sort by 仅在各个reducer里分别排序
distribute by s.symbol 相同 s.symbol 值的会落在相同的reducer里面
distribute by ... sort by ... 可简写为 cluster by ...
Index 创建删除
嵌套查询
select t1.dkey,t1.nkey,t1.ipkey,t1.node_id,t1.time,t1.status,count(*)
from (
select dkey,nkey,ipkey,node_id,
substr(ts,1,13) as time,
CASE
WHEN somev=-1 THEN 'bad'
WHEN somev>3000 THEN 'bad'
WHEN somev>500 THEN 'normal'
ELSE 'good'
END as status
from
somedb.sometb
where date like '201506%' and dkey in ('keya','keyb')
) t1
group by t1.dkey,t1.nkey,t1.ipkey,t1.node_id,t1.time,t1.status
没有评论:
发表评论