On Mon, 17 May 2004, Stijn Vanroye wrote: > Are you sure about that Edmund? > > I have the following query: > select distinct on (task_id, date) task_id, workhour_id, date from > ( > select task_id, workhour_id, begindate as date from workhour > UNION > select task_id, workhour_id, enddate as date from workhour > )as dist1
This gets you first rows distincted by task_id, workhour_id and date and then only rows distincted by task_id and date (and an unpredictable workhour_id). > if I use the query without the top level select, like this: > select task_id, workhour_id, begindate as date from workhour > UNION > select task_id, workhour_id, enddate as date from workhour This gets rows distincted by task_id, workhour_id and date. ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster