1. 程式人生 > >Hive對有null值得一列做avg,count等操作時會過濾掉有NULL值的這一行

Hive對有null值得一列做avg,count等操作時會過濾掉有NULL值的這一行

WITH tmp AS (SELECT null as col1 union all SELECT 2 as col1 union all SELECT 4 as col1 ) SELECT avg(1) from tmp 結果是3; WITH tmp AS (SELECT null as col1 union all SELECT 2 as col1 union all SELECT 4 as col1 ) SELECT count(col1) from tmp 結果是:2 但是SELECT count(1) from tmp 結果是:3