0

Same id having more than one name and the count of the unique names which are associated with the unique id

enter image description here

  • Have you even tried anything??? – Eric Feb 6 at 15:39
0
SELECT id, COUNT(DISTINCT id, name) `count`
FROM `table`
GROUP BY id WITH ROLLUP

If you do not need in total count, it's simplified to:

SELECT id, COUNT(DISTINCT name) `count`
FROM `table`
GROUP BY id
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.