Link to home
Start Free TrialLog in
Avatar of ca1358
ca1358

asked on

Show 0 when Count is Zero

I am getting a count of Records.

What I need to add is, if the count is zero or null  then show the zero has count.

SELECT Count(M_AS400_P112.PCode) AS CountOfPCode, M_AS400_P112.MaintenanceDate, M_AS400_P112.PCode INTO TodayCountAS400P112
FROM M_AS400_P112
GROUP BY M_AS400_P112.MaintenanceDate, M_AS400_P112.PCode;

Open in new window

Avatar of sshah254
sshah254

MSSQL has ISNULL ... check for something similar for the AS400.

Ss
Avatar of ca1358

ASKER

I need syntax of Count(Field) but iif isNull then put a zero.
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Maybe this:

SELECT Count( Nz(M_AS400_P112.PCode , 0 ) ) AS CountOfPCode, M_AS400_P112.MaintenanceDate, M_AS400_P112.PCode INTO TodayCountAS400P112
FROM M_AS400_P112
GROUP BY M_AS400_P112.MaintenanceDate, M_AS400_P112.PCode;

mx
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ca1358

ASKER

Thank you