If i'm not wrong, u can use distinct for the deptno in the select query, this also avoids duplicates . but the thing is u've to specify the distinct only for one column and should be the first column in the select clause.

Pls correct me any gurus , if i'm wrong