Re: [SQL] Order by birthdate

From: Marin D <marin(at)cybernet(dot)bg>
To: Tim J Trowbridge <trowbrid(at)writeme(dot)com>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] Order by birthdate
Date: 1998-06-11 07:49:35
Message-ID: Pine.LNX.3.96.980611103741.7530B-100000@server.iclub.techno-link.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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? =-

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Lendvary Gyorgy 1998-06-11 08:16:31 update by one transaction
Previous Message Tim J Trowbridge 1998-06-11 02:39:44 Order by birthdate