How ad an increasing index to a query result?

Поиск
Список
Период
Сортировка
От Josip
Тема How ad an increasing index to a query result?
Дата
Msg-id 896691c6-f038-4397-afef-d6c3679ef8a1@j39g2000yqh.googlegroups.com
обсуждение исходный текст
Ответы Re: How ad an increasing index to a query result?  (Andrew Bailey <hazlorealidad@gmail.com>)
Re: How ad an increasing index to a query result?  ("Chris Spotts" <rfusca@gmail.com>)
Re: How ad an increasing index to a query result?  (LaMi <lami@datalogiq.net>)
Re: How ad an increasing index to a query result?  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
Re: How ad an increasing index to a query result?  (Thom Brown <thombrown@gmail.com>)
Список pgsql-general
Hello,

Could somebody please try to help me with this problem?
So, let’s say that I have the query:

CREATE SEQUENCE c START 1;

SELECT a, nextval('c') as b
FROM table1
ORDER BY a DESC LIMIT 5;

I.e., I want to pick the 5 largest entries from table1 and show them
alongside a new index column that tells the position of the entry. For
example:

 a  | b
--------
82 | 5
79 | 4
34 | 3
12 | 2
11 | 1

However, when I try this approach, the values of column b don’t follow
the correct order. How should I go about and modify my code?

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

Предыдущее
От: Andrew Bailey
Дата:
Сообщение: 3d Vector Types and operators
Следующее
От: Sam Mason
Дата:
Сообщение: Re: 3d Vector Types and operators