Received: from server.iclub.techno-link.com (server.cybernet.bg [212.36.3.249]) by hub.org (8.8.8/8.7.5) with ESMTP id DAA14679 for ; Thu, 11 Jun 1998 03:57:14 -0400 (EDT) Received: from localhost (marin@localhost) by server.iclub.techno-link.com (8.8.8/8.?.?) with SMTP id KAA07691; Thu, 11 Jun 1998 10:49:35 +0300 Date: Thu, 11 Jun 1998 10:49:35 +0300 (EET DST) From: Marin D X-Sender: marin@server.iclub.techno-link.com To: Tim J Trowbridge cc: pgsql-sql@postgreSQL.org Subject: Re: [SQL] Order by birthdate In-Reply-To: <357F4370.5BB8@writeme.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 10 Jun 1998, Tim J Trowbridge wrote: > > SELECT name,birthdate FROM table WHERE birthdate is not null ORDER BY > date_part('month',birthdate) > > but psql returns: > > ERROR: parser: parse error at or near "(" > > What's the problem? > Two problems here: 1. The date_part() which u use in the order by clause is not in the target list 2. Even if it was it wouldn't work as AFAIK functions are not allowed in the order by clause Try this: SELECT name,birthdate, date_part('month',birthdate) as birth_month FROM table WHERE birthdate is not null ORDER BY birth_month; Any better idea??? Marin -= Why do we need gates in a world without fences? =-