pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Michael Agbaglo <byteshifter@shifted-bytes.de>
To: pgsql-sql@postgresql.org
Subject: Re: how to sort a birthday list ?
Date: Thu, 20 Jun 2002 17:03:52 -0700
Message-ID: <200206201703.52435.josh@agliodbs.com> (raw)
In-Reply-To: <3D122508.70104@shifted-bytes.de>
References: <3D122508.70104@shifted-bytes.de>


Michael,

> SELECT *
> FROM Persons
> WHERE EXTRACT( YEAR FROM AGE(dateofbirth) ) < EXTRACT( YEAR FROM AGE( 
> CURRENT_DATE+60, dateofbirth ) )
> 
> ... but how do I sort the list ?

Easy:

SELECT person_name, person_department,  EXTRACT( YEAR FROM AGE(dateofbirth) ) 
as their_age
FROM Persons
WHERE EXTRACT( YEAR FROM AGE(dateofbirth) ) < EXTRACT( YEAR FROM AGE( 
CURRENT_DATE+60, dateofbirth ) )
ORDER BY their_age, person_name

As an example.





-- 
-Josh Berkus




view thread (7+ messages)  latest in thread

Message-ID: <200206201703.52435.josh@agliodbs.com>
Permalink:  ../200206201703.52435.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200206201703.52435.josh@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: josh@agliodbs.com, byteshifter@shifted-bytes.de
  Subject: Re: how to sort a birthday list ?
  In-Reply-To: <200206201703.52435.josh@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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