I have query as below:
SELECT
COUNT(*)
FROM
(SELECT
h2.hacker_id, COUNT(c2.challenge_id) AS co
FROM
hackers h2
INNER JOIN
challenges c2 ON h2.hacker_id = c2.hacker_id
GROUP BY
h2.hacker_id
HAVING
COUNT(c2.challenge_id) = 1)
But, my query can not execute well and I get this error:
Msg 102, Level 15, State 1, Server WIN-ILO9GLLB9J0, Line 33
Incorrect syntax near ')'
Please help me resolve this.