In DB2, using the following left join
select a.deptno, a.deptname, b.empno
from #dept a
left join #emp b
on a.deptno = b.workdept
on two tables, gets me a list like:
dpt name emp
----------------------
A01 ACCOUNTING 5001
A02 PAYROLL NULL
A03 OPERATIONS 5003
A03 OPERATIONS 5004
A03 OPERATIONS 5007
A05 MAINTENANCE NULL
but I want only the first instance of any dpt. Is there a way to code the left join to pull only the first occurrence, so that it would look like:
dpt name emp
----------------------
A01 ACCOUNTING 5001
A02 PAYROLL NULL
A03 OPERATIONS 5003
A05 MAINTENANCE NULL