smp97
smp97

Reputation: 63

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.

Upvotes: 0

Views: 318

Answers (1)

mck
mck

Reputation: 42422

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

Upvotes: 1

Related Questions