Received: from oxmail.ox.ac.uk (oxmail1.ox.ac.uk [129.67.1.1]) by hub.org (8.9.3/8.9.3) with ESMTP id FAA66463 for ; Thu, 20 Apr 2000 05:22:44 -0400 (EDT) (envelope-from moray.mcconnachie@computing-services.oxford.ac.uk) Received: from ermine.ox.ac.uk ([163.1.2.13]) by oxmail.ox.ac.uk with esmtp (Exim 3.12 #3) id 12iDAN-0005TL-00; Thu, 20 Apr 2000 10:22:31 +0100 Received: from ermine.ox.ac.uk ([163.1.2.13] helo=moraypc ident=root) by ermine.ox.ac.uk with smtp (Exim 3.13 #1) id 12iDAS-00053V-00; Thu, 20 Apr 2000 10:22:36 +0100 Message-ID: <00bc01bfaaa9$c564b650$760e01a3@oucs.ox.ac.uk> From: "Moray McConnachie" To: , References: Subject: Re: Re: GROUPING and ORDERING and CONFUSION Date: Thu, 20 Apr 2000 10:21:12 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Archive-Number: 200004/219 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" To: 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 > >