> I forgot one situation: > > if I run the query like so: > select distinct on (task_id, begindate) task_id, workhour_id, > begindate as date from workhour UNION > select distinct on (task_id, enddate) task_id, workhour_id, enddate > as date from workhour I get yet another value: 2961 rows. > > So I got 3 different result sets for 3 different ways to run the query. > Even in this last case the UNION doesn't seem to only return unique values, > and I will still need the top-level select.
if we suppose this situation possible to program in SQL it causes data-loss in query (i mean unpredictable query result: if you have two records (f=1,b=2),(f=1,b=3) "distinct ON f" makes a value of b meaningless) So you MUST NOT select that way P.S. This situation means: you have wrong data structure. ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])