jeudi 21 septembre 2017

How to get a random integer in BigQuery?

I want to get a random integer between 0 and 9 in BigQuery. I tried the classic

SELECT CAST(10*RAND() AS INT64)

but it's producing numbers between 0 and 10

Adding this question as the results might surprise programmers used to CAST doing a TRUNC in most other languages.




Aucun commentaire:

Enregistrer un commentaire