| От | Tom Lane |
|---|---|
| Тема | Re: [HACKERS] DISTINCT and ORDER BY bug? |
| Дата | |
| Msg-id | 19716.949939003@sss.pgh.pa.us обсуждение |
| Ответ на | Re: [HACKERS] DISTINCT and ORDER BY bug? (Chris <chris@bitmead.com>) |
| Список | pgsql-hackers |
Chris <chris@bitmead.com> writes:
>> select distinct x from foo order by y;
>>
>> which produces ill-defined results.
> Why is this ill-defined? If y is in x then it is also distinct
Huh? The query specifies distinct values of x, and only x.
Consider x y
1 1 1 10 2 0 2 11
"select distinct x" ought to produce one row with x=1, and one row with
x=2, and nothing else. If it implicitly did the distinct on y as well,
you'd get four rows with two x=1 and two x=2, which is not my idea of
"distinct x". But if you don't have four rows out, then there's no
meaningful way to order by y.
6.5.3 in fact produces four rows from this query, which is generally
conceded to be broken behavior.
regards, tom lane
В списке pgsql-hackers по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера