You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by unludo <un...@gmail.com> on 2008/04/08 07:26:15 UTC
limit, offset and random
Hello,
I would like to use the following constraints at the end of some queries:
SELECT a FROM B WHERE c = 'toto' ORDER BY RANDOM() LIMIT 10;
It is supposed to return 10 values randomly from the B table.
In fact I use that with postgresql.
Also if someone knows if ejbql supports a random() like operator in the
order by (I could not find it anywhere).
Thanks in advance, any help much appreciated.
Ludovic
--
View this message in context: http://www.nabble.com/limit%2C-offset-and-random-tp16547686p16547686.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
Re: limit, offset and random
Posted by Øystein Grøvlen <Oy...@Sun.COM>.
unludo wrote:
> OK thanks a lot for your answers.
>
> Regarding the 'ORDER BY RANDOM()', you also plan to have something similar?
ORDER BY RANDOM() already works for me. Example:
ij> select i from t where i < 5;
I
-----------
1
2
3
4
4 rows selected
ij> select i from t where i < 5 order by random();
I
-----------
1
2
4
3
4 rows selected
ij>
--
Øystein
Re: limit, offset and random
Posted by unludo <un...@gmail.com>.
OK thanks a lot for your answers.
Regarding the 'ORDER BY RANDOM()', you also plan to have something similar?
regards
Ludovic
Lance Andersen-2 wrote:
>
> I believe there is an enhancement request to add LIMIT to Derby.
> While it is not part of the SQL standard, most database vendor support
> LIMIT or something similar and it is easier to use than ROW_NUMBER.
> It would be a nice feature to consider.
>
> JDBC 4.1 we will provide a JDBC escape for LIMIT.
>
> Regards
> Lance
> On Apr 8, 2008, at 4:35 AM, Dyre.Tjeldvoll@Sun.COM wrote:
>
>> unludo <un...@gmail.com> writes:
>>
>>> Hello,
>>>
>>> I would like to use the following constraints at the end of some
>>> queries:
>>>
>>> SELECT a FROM B WHERE c = 'toto' ORDER BY RANDOM() LIMIT 10;
>>
>> LIMIT is a non-standard extension. Derby 10.4 (soon to be released)
>> includes the SQL ROW_NUMBER function which will let you do the same
>> thing,
>> although with a different and slightly more verbose syntax.
>>
>> --
>> dt
>
>
>
--
View this message in context: http://www.nabble.com/limit%2C-offset-and-random-tp16547686p16578551.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
Re: limit, offset and random
Posted by Lance Andersen <La...@Sun.COM>.
I believe there is an enhancement request to add LIMIT to Derby.
While it is not part of the SQL standard, most database vendor support
LIMIT or something similar and it is easier to use than ROW_NUMBER.
It would be a nice feature to consider.
JDBC 4.1 we will provide a JDBC escape for LIMIT.
Regards
Lance
On Apr 8, 2008, at 4:35 AM, Dyre.Tjeldvoll@Sun.COM wrote:
> unludo <un...@gmail.com> writes:
>
>> Hello,
>>
>> I would like to use the following constraints at the end of some
>> queries:
>>
>> SELECT a FROM B WHERE c = 'toto' ORDER BY RANDOM() LIMIT 10;
>
> LIMIT is a non-standard extension. Derby 10.4 (soon to be released)
> includes the SQL ROW_NUMBER function which will let you do the same
> thing,
> although with a different and slightly more verbose syntax.
>
> --
> dt
Re: limit, offset and random
Posted by Dy...@Sun.COM.
unludo <un...@gmail.com> writes:
> Hello,
>
> I would like to use the following constraints at the end of some queries:
>
> SELECT a FROM B WHERE c = 'toto' ORDER BY RANDOM() LIMIT 10;
LIMIT is a non-standard extension. Derby 10.4 (soon to be released)
includes the SQL ROW_NUMBER function which will let you do the same thing,
although with a different and slightly more verbose syntax.
--
dt