How to fetch the records which is belongs to only one group in postgresql
You could use count(distinct collage_id) grouping by stud_id in this way:

select   stud_id
from     tbl
group by stud_id
having   count(distinct collage_id) = 1;






| stud_id |
| ------: |
|       6 |
|       7 |



db&lt;>fiddle here

If you want to fetch rows filtering by collage_id:

select *
from   tbl
where  collage_id = 3
and    stud_id in (select   stud_id
                   from     tbl
                   group by stud_id
                   having   count(distinct collage_id) = 1);


Note I've modified a bit your sample data.





_id | stud_id | collage_id | university_id | active
--: | ------: | ---------: | ------------: | :-----
  8 |       7 |          3 |             2 | t     



db&lt;>fiddle here