pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Moray McConnachie <moray.mcconnachie@computing-services.oxford.ac.uk>
To: tim@celestialdesign.co.uk
To: pgsql-sql@postgresql.org
Subject: Re: Re: GROUPING and ORDERING and CONFUSION
Date: Thu, 20 Apr 2000 10:21:12 +0100
Message-ID: <00bc01bfaaa9$c564b650$760e01a3@oucs.ox.ac.uk> (raw)
References: <NBBBLHOPPPPCHCIABAFGKELNCJAA.tim@celestialdesign.co.uk>

If it was literally the way the data went in, you should be able to order by
oid. Alternatively,

SELECT * FROM tablename ORDER BY substring (text(num) from 1 for 2);

should do it.
----------------------------------------------------------------
Moray.McConnachie@computing-services.oxford.ac.uk
----- Original Message -----
From: "Tim Johnson" <tim@celestialdesign.co.uk>
To: <pgsql-sql@postgresql.org>
Sent: Thursday, April 20, 2000 2:28 AM
Subject: [SQL] Re: GROUPING and ORDERING and CONFUSION


> Hello,
>
> I was hoping somebody might be able to help me do this: I have a table
with
> two fields (num int, name text)
>
> num   | name
> ----------------------------------------------
> 15    | First Category Heading
> 1510  | first category subheading
> 1511  | second category subheading
> 1560  | spurious category subheading
> 156010| first spurious category subheading
> 156011| second spurious category subheading
> 16    | Second Category Heading
> 1610  | Second category subheading
> 161010| Second category subheading subheading
>
> and so on...
>
> My problem is I want to pull that data out and group it so that it comes
out
> just the way it went in.. So my page can read:
>
> 15: First Category Heading
> 1510: first category subheading
> 1511: second category subheading
> 16: ... and so on..
>
>
>
> I thought I could probably group by num on the first two digits and order
by
> asc? but I can't find a way to make that work.
>
> Thanks in advance.
>
>
> Tim Johnson
>
>




view thread (3+ messages)  latest in thread

Message-ID: <00bc01bfaaa9$c564b650$760e01a3@oucs.ox.ac.uk>
Permalink:  ../00bc01bfaaa9$c564b650$760e01a3@oucs.ox.ac.uk/
Also on:    postgresql.org/message-id/00bc01bfaaa9$c564b650$760e01a3@oucs.ox.ac.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: moray.mcconnachie@computing-services.oxford.ac.uk, tim@celestialdesign.co.uk
  Subject: Re: GROUPING and ORDERING and CONFUSION
  In-Reply-To: <00bc01bfaaa9$c564b650$760e01a3@oucs.ox.ac.uk>
  References: <NBBBLHOPPPPCHCIABAFGKELNCJAA.tim@celestialdesign.co.uk> <00bc01bfaaa9$c564b650$760e01a3@oucs.ox.ac.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox