How can we help you today?
ORDER BY NEWID()
2 CommentsSorted by Oldest First
VistaDB does not currently support expressions in the ORDER BY clause.
You can work around this by including the expression as a result column and referencing it by position number or by a unique alias:
SELECT TOP 1 *, NewId() as "Order" FROM Table1
ORDER BY "Order";
Note that if the table gets large this will have significant overhead in allocating Guid values and sorting by them over the number of rows of the table. For larger tables there may be a more efficient way to pick a random row--although it gets more complex.
@RobParker ahh oke, thanks for the answer. I will try it in a different way.