Re: Proposed RAND() defn

On 2010-12-02, at 12:12, Andy Seaborne wrote:

>> Maybe I don't understand RAND for SQL well enough but I thought that
>> RAND() returns different numbers in
>> 
>> FILTER(RAND()> 0.5&& RAND()< 0.6)
>> 
>> (if you want the same number assign it in some way)
>> 
>> As RAND() returns different numbers, so
> 
> MySQL:
> 
> select rand() as A , rand() as B from T ;
> 
> +-------------------+-------------------+
> | A                 | B                 |
> +-------------------+-------------------+
> | 0.231994651474054 | 0.353741641485823 |
> +-------------------+-------------------+
> 1 row in set (0.00 sec)

Yes, my draft def'n of RAND() specifies that behaviour, but:

select rand(1) as A , rand(1) as B from foo;
+------------------+------------------+
| A                | B                |
+------------------+------------------+
| 0.40540353712198 | 0.40540353712198 | 
| 0.87161418038571 | 0.87161418038571 | 
+------------------+------------------+
2 rows in set (0.00 sec)

That's important behaviour for usability, due to the bottom up execution of SQL (and SPARQL).

- Steve

-- 
Steve Harris, CTO, Garlik Limited
1-3 Halford Road, Richmond, TW10 6AW, UK
+44 20 8439 8203  http://www.garlik.com/
Registered in England and Wales 535 7233 VAT # 849 0517 11
Registered office: Thames House, Portsmouth Road, Esher, Surrey, KT10 9AD

Received on Thursday, 2 December 2010 13:54:27 UTC