Search code examples
hadoophivebigdatahiveql

How to replace blank value of a column to [null] in hive to calculate SUM


could you please guide.

I have following input table.

enter image description here

I tried below query.

select distinct sum(amount) over partition by date from table1;

Here in the table date is type string and amount is of type double.


Solution

  • You can add a where to remove the rows with blank dates, before doing a group by and sum:

    select date, sum(amount)
    from table1
    where date != ''
    group by date