0

Want to only count the rows that are set and avoid the rows that are not set

SELECT COUNT(DISTINCT member_id) AS total_memebers, 
  COUNT(case member_feesdue when null then 1 else 0 end) AS total_feesdue 
FROM sdg_members
0

2 Answers 2

2

COUNT never counts NULLs. SELECT COUNT(col) FROM tbl is enough.

Sign up to request clarification or add additional context in comments.

Comments

0

I think you are trying to count total_feesdue where it equals to 1?

SELECT COUNT(DISTINCT member_id) AS total_memebers, 
  (SELECT COUNT(*) FROM sdg_members WHERE sdg_members = 1) AS total_feesdue 
FROM sdg_members

1 Comment

I want to count only those rows from the column which has values and avoid the rows in which this column is empty

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.