Re: SELECT * FROM foo OFFSET -1 LIMIT 1

From: Martín Marqués <martin(at)bugs(dot)unl(dot)edu(dot)ar>
To: Markus Bertheau ☭ <twanger(at)bluetwanger(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: SELECT * FROM foo OFFSET -1 LIMIT 1
Date: 2005-06-27 17:17:28
Message-ID: 200506271417.28851.martin@bugs.unl.edu.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

El Lun 27 Jun 2005 12:34, Markus Bertheau ☭ escribió:
> Hi,
>
> is there a reason that
>
> SELECT * FROM t1 OFFSET -1 LIMIT 1
>
> does not return 0 rows? Accordingly
>
> SELECT * FROM t1 OFFSET -1 LIMIT 2
>
> should return 1 row, imo.

From the docs:

The LIMIT clause consists of two independent sub-clauses:

LIMIT { count | ALL }
OFFSET start

count specifies the maximum number of rows to return, while start specifies
the number of rows to skip before starting to return rows. When both are
specified, start rows are skipped before starting to count the count rows to
be returned.

How do you skip -1 rows?

--
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
---------------------------------------------------------
Martín Marqués | Programador, DBA
Centro de Telemática | Administrador
Universidad Nacional
del Litoral
---------------------------------------------------------

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message jimmy.olsen 2005-06-27 17:27:41 pg_attribute.attlen -1 for varchar e pbchar fields
Previous Message Roy Souther 2005-06-27 17:16:58 How can I simply substatue a value in a query?