Get the Record where only Two Records exists in SQL I want to get the parentID where user1 and user2 are using and only the two of them are using.
for example,
ParentTbl
| ID   |           Remarks              |
|------|--------------------------------|
| 1    | only one use this              |
| 2    | two user, _this is the ouput_  |
| 3    | three users use this           |

UserTbl
| ID | UserID | ParentID   |
|----|--------|------------|
| 1  |    1   |      1     |
|_2_ | ___1___|   ___2___  |
|_3_ | ___2___|   ___2___  |
| 4  |    1   |      3     |
| 5  |    2   |      3     |
| 6  |    3   |      3     |

It should be Parent 2
I already have :
select ParentID from UserTbl 
where UserID IN (1,2)
group by ParentID
having COUNT(*) = 2 

But the output is wrong.
If I understand you correctly, what you want is
SELECT ParentID
FROM   UserTbl 
GROUP BY ParentID 
HAVING SUM(CASE WHEN userID IN (1, 2) THEN 1 ELSE 0 END) = 2
AND    COUNT(*) = 2

The first condition SUM(CASE WHEN userID IN (1, 2) THEN 1 ELSE 0 END) = 2 is to check User 1 and 2 are in
The second condition COUNT(*) = 2 users count = 2 (only user 1 and 2)