Re: sort up then down - Mailing list pgsql-sql

From Tom Lane
Subject Re: sort up then down
Date
Msg-id 431.1050274894@sss.pgh.pa.us
Whole thread Raw
In response to sort up then down  ("Randolph Jones" <jonesrf1@qwest.net>)
List pgsql-sql
"Randolph Jones" <jonesrf1@qwest.net> writes:
> I have database fields 1234567891.001;
> I want to sort on first 10 digits descending; (last date first)
> then ascending on the last 3 digit (page numbers)
> the statement below gives the right answer,
> but is this how to do it?

> SELECT  substr(imgname,1,10) AS name, substring(imgname,12,3) AS pg FROM 
> fax GROUP BY imgname, pg ORDER BY name DESC, pg ASC;

The ORDER BY seems fine.  I think the GROUP BY is redundant: if you're
grouping by imgname, there's no effect to grouping by pg as well, no?
        regards, tom lane



pgsql-sql by date:

Previous
From: "Daniel Seichter"
Date:
Subject: SELECT Blobs into a delphi program
Next
From: "Yudha Setiawan"
Date:
Subject: How Do I Hide Trigger ??