Re: Query ordering question

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: ajmcello <ajmcello78(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Query ordering question
Date: 2012-07-03 06:40:46
Message-ID: 9C942DB6-AE24-4326-BB2F-5FA0DE977565@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 3 Jul 2012, at 1:22, ajmcello wrote:

> db=# SELECT name,date,percent,price,time,amount FROM name WHERE amount >= '1000000' AND date='$today' ORDER BY percent DESC;
>
> name | date | percent | price | time | amount
> --------+------------+----------------+---------+----------+----------
> BOB | 2012-07-02 | 63.77 | 8.86 | 14:59:00 | 26975372
> BOB | 2012-07-02 | 63.77 | 8.86 | 15:01:00 | 27001372
> BOB | 2012-07-02 | 64.06 | 8.8755 | 15:04:00 | 27145552
> BOB | 2012-07-02 | 63.77 | 8.86 | 14:57:00 | 26946338
> GIL | 2012-07-02 | 38.72 | 0.6789 | 14:55:00 | 1012880

This output makes no sense with the sort order you specified.
Are you sure that the output matches the query? If it does, is percent a numeric field or is it a varchar where the numbers have varying amount of leading space perhaps?

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pawel Veselov 2012-07-03 07:19:24 errors with high connections rate
Previous Message David Johnston 2012-07-03 01:14:48 Re: Query ordering question