Re: [GENERAL] UNION with more restrictive DISTINCT

2004-12-19 Thread Vincent Hikida
FROM t1 JOIN t2 ON t1.id = t2.id ) - Original Message - From: "Vincent Hikida" <[EMAIL PROTECTED]> To: "peter pilsl" <[EMAIL PROTECTED]>; "PostgreSQL List" <[EMAIL PROTECTED]> Sent: Saturday, December 18, 2004 12:40 AM S

Re: [GENERAL] UNION with more restrictive DISTINCT

2004-12-18 Thread Vincent Hikida
One solution is SELECT COALESCE(t1.id,t2.id) , COALESCE(t1.name,t2.name) FROM t1 FULL JOIN t2 ON t1.id = t2.id - Original Message - From: "peter pilsl" <[EMAIL PROTECTED]> To: "PostgreSQL List" <[EMAIL PROTECTED]> Sent: Wednesday, December 15, 2004 1:03 PM Subject: [GENERA

Re: [GENERAL] UNION with more restrictive DISTINCT

2004-12-15 Thread Martijn van Oosterhout
You probably want something more like: SELECT DISTINCT ON (id), * FROM ( UNION ALL ); The fact that UNION sorts at all is a side-effect of the implementation. The distinct part is part of the SQL spec. Use UNION ALL to get all the rows and then DISTINCT ON to do what you actually want..