Robert Capistrano
Robert Capistrano

Reputation: 63

Empty column with float datatype returns 1 value

I would like to ask something, please be good to me.

This is one of my column fields with its datatype.

column_name: amount_paid datatype: float(13,2)

When I count this column, it returns value 1 even if there's no existing value or inserted on it.

Before Query: enter image description here After Query: enter image description here

Query used: SELECT COUNT(amount_paid), COUNT(amount_unpaid) from transactions

I want to achieved a Zero(0) value because of my own reason.

Please be good to me, thank you!

Upvotes: 0

Views: 140

Answers (2)

Ntwobike
Ntwobike

Reputation: 2741

I think you need sum not count.

count is use to count rows doc

sum is use to accumulate the value of the field doc, you might need to use a group by clause

SELECT SUM(amount_paid), SUM(amount_unpaid) from transactions

Upvotes: 2

Ramiro Vargas
Ramiro Vargas

Reputation: 1

Has to be null to count like Cero you can do something like this

    UPDATE table SET column = NULL WHERE test = "example";

Upvotes: -1

Related Questions