>
> select distinct on (date, employee_id) employee_id, date from
> (
> select distinct on (begindate, employee_id) begindate as date, employ=
> ee_id from workhour
> UNION
> select distinct on (enddate, employee_id) enddate as date, employee_i=
> d from workhour
> )as dist
>
>
Just as a side note
If you don't use ORDER BY when using DISTINCT ON
you'll have unpredictable results.
Regards, Christoph