Zkuste toto:
select a.id from Table1 a
inner join Table1 b on a.uid = b.uid and b.dept = 'dept1';
Ukázka:http://sqlfiddle.com/#!2/05774/4
Zkuste toto:
select a.id from Table1 a
inner join Table1 b on a.uid = b.uid and b.dept = 'dept1';
Ukázka:http://sqlfiddle.com/#!2/05774/4