Skip to content
Advertisement

Return count zero if null

Is there anyway to return 0 when count for a specific column is null. I want to return zero when the count of client_order_id is null instead of the query returning 1.

What I have tried:

Requested: Any assistance would be appreciated!

Advertisement

Answer

Your query:

should be doing what you want. If client_order_id is NULL, then the value should be 0.

So, what looks like a NULL value is not a NULL value. This could occur if the column were a string and the value the empty string. If that is the case, you can use nullif():

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement