Re: select random order by random

Поиск
Список
Период
Сортировка
От Lee Keel
Тема Re: select random order by random
Дата
Msg-id 76758090F8686C47A44B6FF52514A1D30904E33A@hermes.uai.int
обсуждение исходный текст
Ответы Re: select random order by random
Список pgsql-general
> -----Original Message-----
> From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-
> owner@postgresql.org] On Behalf Of piotr_sobolewski
> Sent: Thursday, November 01, 2007 9:25 AM
> To: pgsql-general@postgresql.org
> Subject: [GENERAL] select random order by random
>
> Dear sirs,
>
> I was very surprised when I executed such SQL query (under PostgreSQL
> 8.2):
> select random() from generate_series(1, 10) order by random();
>
> I thought I would receive ten random numbers in random order. But I
> received
> ten random numbers sorted numerically:
>       random
> -------------------
>  0.102324520237744
>   0.17704638838768
>  0.533014383167028
>   0.60182224214077
>  0.644065519794822
>  0.750732169486582
>  0.821376844774932
>   0.88221683120355
>  0.889879426918924
>  0.924697323236614
> (10 rows)
>
> I don't understand - why the result is like that? It seems like in each
> row
> both random()s were giving the same result. Why is it like that? What
> caused
> it?
>
> --
> Piotr Sobolewski
> http://www.piotrsobolewski.w.pl
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
>        choose an index scan if your joining column's datatypes do not
>        match
[Lee Keel]

Would this not have to do with the 'order by' you added to the end of the
statement?  If you remove the order by clause, then it works for me...

-LK


This email and any files transmitted with it are confidential and intended solely for the use of the individual or
entityto whom they are addressed. If you have received this email in error please notify the sender. This message
containsconfidential information and is intended only for the individual named. If you are not the named addressee you
shouldnot disseminate, distribute or copy this e-mail. 

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

Предыдущее
От: Jeff Amiel
Дата:
Сообщение: Re: AutoVacuum Behaviour Question
Следующее
От: Jeff MacDonald
Дата:
Сообщение: Solaris 10, mod_auth_pgsql2