Re: sort / limit / range problem

From: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)uk>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: sort / limit / range problem
Date: 2003-03-05 18:59:06
Message-ID: Pine.LNX.4.44.0303051658400.5374-100000@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)matrix(dot)gatewaynet(dot)com
mantzios(at)softlab(dot)ece(dot)ntua(dot)gr

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message speakeasy 2003-03-05 19:59:33 View - Join based on dis-similar data types
Previous Message Gary Stainburn 2003-03-05 16:00:12 Re: sort / limit / range problem