Re: how to sort a birthday list ?

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Michael Agbaglo <byteshifter(at)shifted-bytes(dot)de>, pgsql-sql(at)postgresql(dot)org
Subject: Re: how to sort a birthday list ?
Date: 2002-06-21 00:03:52
Message-ID: 200206201703.52435.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2002-06-21 00:13:03 SQL Challenge: Skip Weekends
Previous Message Josh Berkus 2002-06-21 00:00:26 Re: SQL performance issue with PostgreSQL compared to