0

My Mysql table look like this

Field A         Field B
Red             yes
Blue                yes
Red             no
Green           no
Blue                yes
Blue                yes
Green           no
Green           yes
Red             no

I want the result to be:

Red     1
Blue        3
Green   1

Any help

1

2 Answers 2

1
SELECT FieldA, count(FieldA)
FROM table
WHERE table.FieldB = "yes"
GROUP BY FieldA
Sign up to request clarification or add additional context in comments.

Comments

0

conditional count

SELECT FieldA, COUNT( CASE WHEN FieldB = 'Yes' THEN 1 END)
FROM YourTable
GROUP BY FieldA

Comments

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.