pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Order by birthdate
3+ messages / 3 participants
[nested] [flat]

* Order by birthdate
@ 1998-06-11 02:39 Tim J Trowbridge <trowbrid@writeme.com>
  1998-06-11 07:49 ` Re: [SQL] Order by birthdate Marin D <marin@cybernet.bg>
  1998-06-11 10:52 ` Re: [SQL] Order by birthdate Jose' Soares Da Silva <sferac@bo.nettuno.it>
  0 siblings, 2 replies; 3+ messages in thread

From: Tim J Trowbridge @ 1998-06-11 02:39 UTC (permalink / raw)
  To: pgsql-sql

I'm trying to generate a birthday list ordered by month, then by day. 
This is what I thought would work...

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?

--
Tim J Trowbridge                         trowbrid@writeme.com
Interested in my genealogy?          http://www.execpc.com/~trowbrid



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [SQL] Order by birthdate
  1998-06-11 02:39 Order by birthdate Tim J Trowbridge <trowbrid@writeme.com>
@ 1998-06-11 07:49 ` Marin D <marin@cybernet.bg>
  1 sibling, 0 replies; 3+ messages in thread

From: Marin D @ 1998-06-11 07:49 UTC (permalink / raw)
  To: Tim J Trowbridge <trowbrid@writeme.com>; +Cc: 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? =-





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [SQL] Order by birthdate
  1998-06-11 02:39 Order by birthdate Tim J Trowbridge <trowbrid@writeme.com>
@ 1998-06-11 10:52 ` Jose' Soares Da Silva <sferac@bo.nettuno.it>
  1 sibling, 0 replies; 3+ messages in thread

From: Jose' Soares Da Silva @ 1998-06-11 10:52 UTC (permalink / raw)
  To: Tim J Trowbridge <trowbrid@writeme.com>; +Cc: pgsql-sql

On Wed, 10 Jun 1998, Tim J Trowbridge wrote:

> I'm trying to generate a birthday list ordered by month, then by day. 
> This is what I thought would work...
> 
> SELECT name,birthdate FROM table WHERE birthdate is not null ORDER BY
> date_part('month',birthdate)

I don't understand why you need specify month to sort tuples, you may order
it by birthday, but if you want it anyway try this:

SELECT name, EXTRACT(month FROM birthdate) AS mese
      FROM table WHERE birthdate is not null
      ORDER BY mese
> 
> but psql returns:
> 
> ERROR:  parser: parse error at or near "("
> 
> What's the problem?
Seems that order by doesn't supports a function as parameter.
                                  Jose'




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~1998-06-11 10:52 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-06-11 02:39 Order by birthdate Tim J Trowbridge <trowbrid@writeme.com>
1998-06-11 07:49 ` Marin D <marin@cybernet.bg>
1998-06-11 10:52 ` Jose' Soares Da Silva <sferac@bo.nettuno.it>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox