pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: sort / limit / range problem
4+ messages / 3 participants
[nested] [flat]
* sort / limit / range problem
@ 2003-03-05 14:37 Gary Stainburn <gary.stainburn@ringways.co.uk>
2003-03-05 07:47 ` Re: sort / limit / range problem Tomasz Myrta <jasiek@klaster.net>
2003-03-05 18:59 ` Re: sort / limit / range problem Achilleus Mantzios <achill@matrix.gatewaynet.com>
0 siblings, 2 replies; 4+ messages in thread
From: Gary Stainburn @ 2003-03-05 14:37 UTC (permalink / raw)
To: pgsql-sql
Hi folks,
I've got a glossary table that I'm trying to render to HTML. However, I've
got a problem when using order by and limit. Below is an example of a psql
session showing my problem. Anyone got any reasons why the last select misses
'Driver'?
nymr=# select glterm from glossary where glterm like 'D%' order by glterm;
glterm
----------------
Dampers
Dart
Detonators
Disposal
Dome
Draw Bar
Driver
Driving Wheels
Duty Fitter
(9 rows)
nymr=# select glterm from glossary where glterm > 'Driving Wheels' limit 1;
glterm
-------------
Duty Fitter
(1 row)
nymr=# select glterm from glossary where glterm > 'Draw Bar' limit 1;
glterm
----------------
Driving Wheels
(1 row)
nymr=# \d glossary
Table "glossary"
Attribute | Type | Modifier
-----------+-----------------------+-----------------------------------------------------
glid | integer | not null default
nextval('glossary_glid_seq'::text)
glterm | character varying(30) | not null
gldesc | text |
Indices: glossary_pkey,
glossary_term_index
nymr=#
--
Gary Stainburn
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: sort / limit / range problem
2003-03-05 14:37 sort / limit / range problem Gary Stainburn <gary.stainburn@ringways.co.uk>
@ 2003-03-05 07:47 ` Tomasz Myrta <jasiek@klaster.net>
1 sibling, 0 replies; 4+ messages in thread
From: Tomasz Myrta @ 2003-03-05 07:47 UTC (permalink / raw)
To: Gary Stainburn <gary.stainburn@ringways.co.uk>; pgsql-sql
> Hi folks,
>
> I've got a glossary table that I'm trying to render to HTML.
> However, I've got a problem when using order by and limit. Below
> is an example of a psql session showing my problem. Anyone got any
> reasons why the last select misses 'Driver'?
>
Everything is ok. Without order by, limit has undeterminated result. It is
described in Postgresql documentation.
Try this:
select glterm from glossary where glterm > 'Driving Wheels'
order by glterm limit 1
select glterm from glossary where glterm > 'Draw Bar'
order by glterm limit 1
Regards,
Tomasz Myrta
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: sort / limit / range problem
2003-03-05 14:37 sort / limit / range problem Gary Stainburn <gary.stainburn@ringways.co.uk>
@ 2003-03-05 18:59 ` Achilleus Mantzios <achill@matrix.gatewaynet.com>
2003-03-05 16:00 ` Re: sort / limit / range problem Gary Stainburn <gary.stainburn@ringways.co.uk>
1 sibling, 1 reply; 4+ messages in thread
From: Achilleus Mantzios @ 2003-03-05 18:59 UTC (permalink / raw)
To: Gary Stainburn <gary.stainburn@ringways.co.uk>; +Cc: pgsql-sql
On Wed, 5 Mar 2003, Gary Stainburn wrote:
> Hi folks,
>
> I've got a glossary table that I'm trying to render to HTML. However, I've
> got a problem when using order by and limit. Below is an example of a psql
> session showing my problem. Anyone got any reasons why the last select misses
> 'Driver'?
You forgot ORDER BY glterm
>
> nymr=# select glterm from glossary where glterm like 'D%' order by glterm;
> glterm
> ----------------
> Dampers
> Dart
> Detonators
> Disposal
> Dome
> Draw Bar
> Driver
> Driving Wheels
> Duty Fitter
> (9 rows)
>
> nymr=# select glterm from glossary where glterm > 'Driving Wheels' limit 1;
> glterm
> -------------
> Duty Fitter
> (1 row)
>
> nymr=# select glterm from glossary where glterm > 'Draw Bar' limit 1;
> glterm
> ----------------
> Driving Wheels
> (1 row)
>
> nymr=# \d glossary
> Table "glossary"
> Attribute | Type | Modifier
> -----------+-----------------------+-----------------------------------------------------
> glid | integer | not null default
> nextval('glossary_glid_seq'::text)
> glterm | character varying(30) | not null
> gldesc | text |
> Indices: glossary_pkey,
> glossary_term_index
>
> nymr=#
>
>
--
==================================================================
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
Nikis 4, Glyfada
Athens 16610
Greece
tel: +30-210-8981112
fax: +30-210-8981877
email: achill@matrix.gatewaynet.com
mantzios@softlab.ece.ntua.gr
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: sort / limit / range problem
2003-03-05 14:37 sort / limit / range problem Gary Stainburn <gary.stainburn@ringways.co.uk>
2003-03-05 18:59 ` Re: sort / limit / range problem Achilleus Mantzios <achill@matrix.gatewaynet.com>
@ 2003-03-05 16:00 ` Gary Stainburn <gary.stainburn@ringways.co.uk>
0 siblings, 0 replies; 4+ messages in thread
From: Gary Stainburn @ 2003-03-05 16:00 UTC (permalink / raw)
To: Achilleus Mantzios <achill@matrix.gatewaynet.com>; +Cc: Tomasz Myrta <jasiek@klaster.net>; pgsql-sql
On Wednesday 05 Mar 2003 6:59 pm, you wrote:
> On Wed, 5 Mar 2003, Gary Stainburn wrote:
> > Hi folks,
> >
> > I've got a glossary table that I'm trying to render to HTML. However,
> > I've got a problem when using order by and limit. Below is an example of
> > a psql session showing my problem. Anyone got any reasons why the last
> > select misses 'Driver'?
>
> You forgot ORDER BY glterm
Thanks you too, sometimes you can't see the wood for the trees
Gary
>
> > nymr=# select glterm from glossary where glterm like 'D%' order by
> > glterm; glterm
> > ----------------
> > Dampers
> > Dart
> > Detonators
> > Disposal
> > Dome
> > Draw Bar
> > Driver
> > Driving Wheels
> > Duty Fitter
> > (9 rows)
> >
> > nymr=# select glterm from glossary where glterm > 'Driving Wheels' limit
> > 1; glterm
> > -------------
> > Duty Fitter
> > (1 row)
> >
> > nymr=# select glterm from glossary where glterm > 'Draw Bar' limit 1;
> > glterm
> > ----------------
> > Driving Wheels
> > (1 row)
> >
> > nymr=# \d glossary
> > Table "glossary"
> > Attribute | Type | Modifier
> > -----------+-----------------------+-------------------------------------
> >---------------- glid | integer | not null default
> > nextval('glossary_glid_seq'::text)
> > glterm | character varying(30) | not null
> > gldesc | text |
> > Indices: glossary_pkey,
> > glossary_term_index
> >
> > nymr=#
--
Gary Stainburn
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2003-03-05 18:59 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-03-05 14:37 sort / limit / range problem Gary Stainburn <gary.stainburn@ringways.co.uk>
2003-03-05 07:47 ` Tomasz Myrta <jasiek@klaster.net>
2003-03-05 18:59 ` Achilleus Mantzios <achill@matrix.gatewaynet.com>
2003-03-05 16:00 ` Gary Stainburn <gary.stainburn@ringways.co.uk>
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