Thread: order by question

order by question

From
"Duncan Adams (DNS)"
Date:
hi all

i have a table that holds reference point for a grid
(computer room floor) the references are laid out as
following.

Horizontal         AA to EF
vertical(rows)     01 to 32

the references are stored as a single value e.g.

AA01, AA02 to EF32

Now my question, is it possible to do a query and return
the values ordered by the last two numbers (order by rows)
and if so how?

Re: order by question

From
"Duncan Adams (DNS)"
Date:
yip that sets me on the correct path.

have been thinking of re-doing the complete database. thing is that in this
case, the guys capturing the data some times type place DE/DF26 for double
cabinets which is why the data model was done that way (i think) no one
thought that reports on rows would be wanted at the time.

thanx again
duncan

-----Original Message-----
From: Allan Engelhardt [mailto:allane@cybaea.com.INVALID.Make.me.valid]
Sent: Tuesday, February 05, 2002 12:13 PM
To: Duncan Adams (DNS)
Subject: Re: [NOVICE] order by question


test=# create table t(p text);
CREATE
test=# insert into t values ('AA01');
INSERT 344153 1
test=# insert into t values ('AA02');
INSERT 344154 1
test=# insert into t values ('EF01');
INSERT 344155 1
test=# insert into t values ('AB01');
INSERT 344156 1
test=# select * from t order by substring(p from 3 for 2), p;
   p
------
  AA01
  AB01
  EF01
  AA02
(4 rows)


You want the 'Functions and Operators' section in the 'User's Guide'.  You
may
also want to (re-)consider your data model.

Hope this helps a little.


Allan

Duncan Adams (DNS) wrote:

> hi all
>
> i have a table that holds reference point for a grid
> (computer room floor) the references are laid out as
> following.
>
> Horizontal         AA to EF
> vertical(rows)     01 to 32
>
> the references are stored as a single value e.g.
>
> AA01, AA02 to EF32
>
> Now my question, is it possible to do a query and return
> the values ordered by the last two numbers (order by rows)
> and if so how?
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>