| От | Tom Lane |
|---|---|
| Тема | Re: window function and order by |
| Дата | |
| Msg-id | 25569.1387584533@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | window function and order by (Torsten Förtsch <torsten.foertsch@gmx.net>) |
| Список | pgsql-general |
=?ISO-8859-1?Q?Torsten_F=F6rtsch?= <torsten.foertsch@gmx.net> writes:
> select id, buy_price, sum(buy_price) over (order by id) sum
> from fmb
> where 202300<=id and id<=202400
> order by id;
> Do I need the ORDER BY clause at the end? Or does the ORDER BY in the
> window function already define the order of the result set?
According to the standard, you'd need the ORDER BY to guarantee any
particular ordering of the output. However, our implementation will
deliver the rows in the window function's order as long as there's
only one window function order (otherwise you get a more-or-less-
random one of them...). It won't cost anything to have the ORDER BY
though, so I'd recommend keeping it.
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера