Reputation: 181
I have got the following query, which shows me a 0 or 1 if they entered fields in their profile.
select id,
count(users.firstname),
count(users.lastname),
count(users.gender),
count(users.country),
count(users.address_one),
count(users.city),
count(users.zipcode),
count(users.housenumber),
count(users.phonenumber),
count(users.educationlevel_id)
from users
group by id;
How do I sum all the counts of this and group it by id?
select id, SUM(
count(users.firstname)+
count(users.lastname)+
count(users.gender)+
count(users.country)+
count(users.address_one)+
count(users.city)+
count(users.zipcode)+
count(users.housenumber)+
count(users.phonenumber)+
count(users.educationlevel_id)
) as smartbio_check
from users
group by id, smartbio_check;
this query doesnt work
Upvotes: 1
Views: 41
Reputation: 72165
Simply add the count
values:
select id,
count(users.firstname) +
count(users.lastname) +
count(users.gender) +
count(users.country) +
count(users.address_one) +
count(users.city) +
count(users.zipcode) +
count(users.housenumber) +
count(users.phonenumber) +
count(users.educationlevel_id) as smartbio_check
from users
group by id
Upvotes: 1