Group the rows in the userLogins
table by the userId
column where the userName
matches foo bar
.
If the count of those groups are greater than one, show the user id and count.
SELECT
"userId", count("userId")
FROM
"userLogins"
WHERE
"userName" = 'foo bar'
GROUP BY
"userId"
HAVING
count("userId") > 1 ;