Prøv denne:
select a.id from Table1 a
inner join Table1 b on a.uid = b.uid and b.dept = 'dept1';
Demo:http://sqlfiddle.com/#!2/05774/4
Prøv denne:
select a.id from Table1 a
inner join Table1 b on a.uid = b.uid and b.dept = 'dept1';
Demo:http://sqlfiddle.com/#!2/05774/4