Hello Nathan,
> Is there any way to achieve 'ORDER BY RANDOM() LIMIT 1' in a sparql
> query using virtuoso?
Consider using
sparql select <whatever> order by asc( bif:rnd(2000000000,
<list_of_selection_columns>)) limit 1 ;
where two billions is big enough to provide variety of sorting criterion
but not too big so it's a plain integer on any platform, and
<list_of_selection_columns> enumerates columns that forms a unique key
of the tabular result set. E.g.
sparql select ?s where { ?s a ?t } order by asc( bif:rnd(10, ?s)) limit
1 ;
Note that it will not work without ", ?s" is in call of bif:rnd() even
if no arguments after the first one are really used by the called
function. In case of "self-evident"
sparql select ?s where { ?s a ?t } order by asc( bif:rnd(2000000000))
limit 1 ;
query, an SQL compiler may prove that the result of bif:rnd() call does
not depend on returned value so it can be calculated only once, at the
very beginning of the query run, before the selection takes place, so
the sorting will be equivalent to "order by asc(constant)", i.e.,
entirely useless.
Best Regards,
Ivan Mikhailov
OpenLink Software
http://virtuoso.openlinksw.com