how to replace NULL values with 0 when calculating the AVG in HIVE -


i'm calculating avg column in hive (using windowing function). query looks this

select avg(price) (partition cust_id order mnth desc rows between 1 following , 12 following) 

the price column has null values , avg function not consider them in calculation. need want null values dealt 0. use nvl follows

select avg(nvl(price)) (partition cust_id order mnth desc rows between 1 following , 12 following) 

however doesn't work. how can deal problem?

select avg(nvl(price, 0))

you forgot second parameter (default_value)


Comments