0

I have a mysql table called Game which has two columns, Name and Score. I want to select only the Names whose scores have been atleast 100 and atleast twice. In the below example Ron and Mary will get selected. I am not sure how to write the select statement for this.

Game table

enter image description here

0

1 Answer 1

3

Use GROUP BY with a HAVING clause:

SELECT Name
FROM mytable
GROUP BY Name
HAVING COUNT(CASE WHEN Score >= 100 THEN 1 END) >= 2

HAVING clause checks for Name groups, having at least two records with Score >= 100.

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

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.