stored procedures - In MySQL, get number of pregnant women who received 3 ANC checkups -
i working on project required find out total number of pregnant women have received 3 anc(ante-natal care) checkups done.
a pregnant women said receive 3 anc checkups if 3 of 4 columns(visit1_date,visit2_date,visit3_date , visit4_date) have value.
for this, need calculate count of number of rows 3 of 4 columns given in table not null.
so, basically, required find count of rows 3 of
visit1_date, visit2_date,visit3_date,visit4_date not null
my table has columns individually each of visit dates
i have tried using ifnull, have no idea if help.
in mysql, boolean operation treated number in numeric context, 1 true , 0 false. makes easy count number of non-null values:
select count(*) table t ((visit1_date not null) + (visit2_date not null) + (visit3_date not null) + (visit4_date not null) ) >= 3;
Comments
Post a Comment