> Richard, Before you "fix" it, I'm not convinced it is broken.
>
> >From MS SQL server
>
> create table _names (N varchar(5));
> insert into _names values('a');
> insert into _names values('b');
> insert into _names values('c');
> insert into _names values('d');
> insert into _names values('e');
mySQL differs from MS SQL in it random function handling:
SELECT i, RAND() AS R1, RAND() AS R2 FROM z where RAND() < .4;
iR1R2
1 0.531666 0.692986
3 0.743755 0.906643
4 0.789811 0.04321
6 0.977431 0.576784
8 0.284047 0.336876
Different values for R1 and R2 (each call
, August 29, 2008 9:39 AM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] problem using random() in queries
Noah Hart <[EMAIL PROTECTED]> wrote:
> I would expect that multiple calls to random always return different
> values, even if in the same line.
>
> The fact that we are ali
Noah Hart <[EMAIL PROTECTED]> wrote:
> I would expect that multiple calls to random always return different
> values, even if in the same line.
>
> The fact that we are aliasing random by a column name makes no
> difference to me.
What about this:
select name, RNDValue
from (
select name, ran
Richard, Before you "fix" it, I'm not convinced it is broken.
>From MS SQL server
create table _names (N varchar(5));
insert into _names values('a');
insert into _names values('b');
insert into _names values('c');
insert into _names values('d');
insert into _names values('e');
select N, RAND()
On Aug 28, 2008, at 12:00 PM, Igor Tandetnik wrote:
> Tmb <[EMAIL PROTECTED]> wrote:
>> I created a SQLite database where a table 'names' is located. This
>> table stores just a single column called 'name'. Now I tried for test
>> purposes to create a random number within range [0..1] for each
>>
Igor Tandetnik wrote:
>
> It looks like random() is run twice for each row - once in WHERE clause
> and again in the SELECT clause. This looks like a bug.
>
I agree, this looks like a bug. This is a simpler query that shows the
same problem.
sqlite> create table t (id, a);
sqlite> select a, r
Tmb wrote:
> I created a SQLite database where a table 'names' is located. This table
> stores just a single column called 'name'. Now I tried for test purposes to
> create a random number within range [0..1] for each record in the table
> using a SELECT statement like this:
>
> select name, (rand
Tmb <[EMAIL PROTECTED]> wrote:
> Igor Tandetnik wrote:
>>
>> Try this:
>>
>> select name, RNDValue
>> from (
>> select name, (random() / 9223372036854775807.0 + 1.0) / 2.0 as
>> RNDValue from names
>> )
>> where RNDValue >= 0.99;
>>
>
> Thank you for your answer. I tried the subselect and it se
Igor Tandetnik wrote:
>
> Try this:
>
> select name, RNDValue
> from (
> select name, (random() / 9223372036854775807.0 + 1.0) / 2.0 as
> RNDValue from names
> )
> where RNDValue >= 0.99;
>
> Igor Tandetnik
>
>
Thank you for your answer. I tried the subselect and it seems that there
Tmb <[EMAIL PROTECTED]> wrote:
> I created a SQLite database where a table 'names' is located. This
> table stores just a single column called 'name'. Now I tried for test
> purposes to create a random number within range [0..1] for each
> record in the table using a SELECT statement like this:
>
>
I created a SQLite database where a table 'names' is located. This table
stores just a single column called 'name'. Now I tried for test purposes to
create a random number within range [0..1] for each record in the table
using a SELECT statement like this:
select name, (random() / 922337203685477
12 matches
Mail list logo