Re: Number the lines

Поиск
Список
Период
Сортировка
От missive@frontiernet.net (Lee Harr)
Тема Re: Number the lines
Дата
Msg-id 9nugup$20cg$1@news.tht.net
обсуждение исходный текст
Ответ на Number the lines  (yaubi@yaubi.com (Yoann))
Список pgsql-sql
On 14 Sep 2001 05:05:49 -0700, Yoann <yaubi@yaubi.com> wrote:
> how can I number the result's lines of a sql query ?
> 
> explaination : I have a query which return me a list of values. I need
> to order them (it's ok, easy ;) and then number the lines. The goal is
> then to extract, for example, "the third maximum value".
> 

CREATE TABLE value (i integer);

INSERT INTO i VALUES (1);
INSERT INTO i VALUES (3);
INSERT INTO i VALUES (2);
INSERT INTO i VALUES (1);
INSERT INTO i VALUES (5);
INSERT INTO i VALUES (2);

CREATE VIEW ordered AS SELECT i FROM value ORDER BY i DESC;

BEGIN;

CREATE SEQUENCE seq;

SELECT nextval('seq') as n, i INTO TEMP TABLE t FROM ordered;

SELECT i FROM t WHERE n=3;


-- IANADBA, but something like this might work...



В списке pgsql-sql по дате отправления:

Предыдущее
От: Hans-Juergen Schoenig
Дата:
Сообщение: Re: How to Get Timestamp From SECONDS?
Следующее
От: Hans-Juergen Schoenig
Дата:
Сообщение: Re: Checking for table existence