First write a query to find widgets with only one comment:
Code:
SELECT
WIDGET_ID
FROM
WIDGET_COMMENTS
HAVING
COUNT(WIDGET_ID) = 1
From here you'll want to bring in the users name from the user table, and count em up again..
Code:
SELECT
U.NAME, COUNT(U.NAME) AS NUMBER_OF_WIDGETS
FROM
(SELECT
WIDGET_ID, USER_ID
FROM
WIDGET_COMMENTS
HAVING
COUNT(USER_ID) = 1) AS SCW
LEFT JOIN USERS U ON SCW.USER_ID = U.USER_ID
GROUP BY
U.NAME
One problem with this approach is that if a user comments on the widget more than once, it will be excluded even if someone else hasn't done so. This can be solved by motifiying the starting query.
Bookmarks