Hi Maxwell,
You can also achieve it through JavaScript as well you can generate a random number using random() function first you need to get the total count of the aggregate then pass it in your JavaScript through input parameter
it will return a random number, you can use it to fetch the data from aggregate.
I have attached OML for the reference.
Sample- Link
I hope this will help
Thanks
Tousif khan