Subject Re: [firebird-support] Is a bug ordering by date, time?
Author Woody (TMW)
From: "lmmolinerocasares" <soporte@...>
> I use Firebird 1.5.2-473, and until now when there was a problem with
> the query result always was my mistake, but this time I checked the
> query carefully and I think maybe there is a bug.
> This is the case: I have a table with one date field (date of
> admission) and one time field (time of admission), if I use a select
> query with ascending order I get the right data:
>
> select NREC,DATE_ADMIN,TIME_ADMIN
> from INGRESOS
> where ID=12
> order by DATE_ADMIN,TIME_ADMIN
>
> NREC DATE_ADMIN TIME_ADMIN
> 21 29/01/2004 10:00:00
> 4 30/04/2004 2:05:00
> 8 30/04/2004 3:00:00
> 20 19/05/2004 16:06:00
>
> But if I try it in the reverse order, descending, I get an amazing result:
>
> select NREC,DATE_ADMIN,TIME_ADMIN
> from INGRESOS
> where ID=12
> order by DATE_ADMIN,TIME_ADMIN desc
>
> NREC DATE_ADMIN TIME_ADMIN
> 21 29/01/2004 10:00:00
> 8 30/04/2004 3:00:00
> 4 30/04/2004 2:05:00
> 20 19/05/2004 16:06:00
>
> I copied real data in this message.
>
> Does anyone know about this problem? Am I completely blind and doing
> something wrong?
>

Guess I'm blind, too. I don't see a problem. You are ordering by date first
in ascending order, then by time in descending order. That's what the data
shows and that's what you asked for.

If you want both date and time in descending order, you have to request it
explicitly:

order by DATE_ADMIN DESC, TIME_ADMIN DESC

HTH
Woody (TMW)