X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 08963474E5C for ; Mon, 24 Feb 2003 08:49:40 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 64366-05 for ; Mon, 24 Feb 2003 08:49:29 -0500 (EST) Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by postgresql.org (Postfix) with SMTP id AB528474E53 for ; Mon, 24 Feb 2003 08:49:28 -0500 (EST) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Mon Feb 24 14:49:31 2003 +0100 Received: œby rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id OAA07482; Mon, 24 Feb 2003 14:49:31 +0100 (MET) Message-ID: <3E5A22EA.B1904F75@rodos.fzk.de> Date: Mon, 24 Feb 2003 14:49:30 +0100 From: Christoph Haller X-Mailer: Mozilla 4.77 [en] (X11; U; HP-UX B.10.20 9000/780) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Cc: mallah@trade-india.com Subject: Re: Help with query involving aggregation and joining. Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/529 X-Sequence-Number: 11927 > > ERROR: > SELECT DISTINCT ON expressions must match > initial ORDER BY expressions may be gotten over by > wrapping the first query result in a subselect. > > not sure though if its proper. > regds > mallah. > > test=# SELECT * from ( SELECT distinct on (a.id) b.id > ,courseid,name,submission from course a join history b on > (a.id=b.courseid) ) as results order by results.submission desc; > I'm currently working with select version(); version --------------------------------------------------------------- PostgreSQL 7.2.3 on hppa-hp-hpux10.20, compiled by GCC 2.95.2 (1 row) I've used your table definitions and sample data you've sent earlier and do not receive an error message on the above SELECT statement. Did you? Regards, Christoph