1. 程式人生 > >培訓系列16--hive 的條件語句和聚合函式

培訓系列16--hive 的條件語句和聚合函式

一。條件表達

case when ... then when .... then ... when ... then ...end

select film_id,rpad(title,20," "),case when rating in ("G","PG","PG-13") then "YOUNG" WHEN RATING=="NC-17" THEN "17 AND UP" WHEN RATING="R" THEN "Mature" else "Unrated" end from film;

isnull() 函式


nvl(field ,field/date)
函式如果是空的話用後面的資料或者另外一個欄位填空

二聚合函式