Re: [SQL] how to sort a birthday list ?

2002-06-21 Thread Michael Agbaglo
David Stanaway wrote: > > How about: > ORDER BY dateofbirth > > > doesn't work: it's sorted by YEAR ... ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] how to sort a birthday list ?

2002-06-21 Thread Michael Agbaglo
Dear Josh, if you sort by AGE then the order will be young -> old or vice versa. I'd like to have the list sorted as interval birthDAY, birthMONTH and DAY from NOW() and MONTH from NOW(). example: 22.06.64 Person-1 26.06.50 Person-2 01.08.69 Person-3 02.08.71 Person-4 ... of course you could

[SQL] how to sort a birthday list ?

2002-06-20 Thread Michael Agbaglo
Hi ! there's a nice query for retrieving the people who have their birthday in the next n days: (taken from Joe Celko's SQL for Smarties, 1st Ed., p. 76) SELECT * FROM Persons WHERE EXTRACT( YEAR FROM AGE(dateofbirth) ) < EXTRACT( YEAR FROM AGE( CURRENT_DATE+60, dateofbirth ) ) ... but how d