title: How to get a random integer in BigQuery?
body: <p>I want to get a random integer between 0 and 9 in BigQuery. I tried the classic </p>
  
  <pre><code>SELECT CAST(10*RAND() AS INT64)
  </code></pre>
  
  <p>but it's producing numbers between 0 and 10</p>
  
  <p><em>Adding this question as the results might surprise programmers used to <code>CAST</code> doing a <code>TRUNC</code> in most other languages.</em></p>
  
  <p><em>Note this weird distribution of results:</em></p>
  
  <p><a href="https://i.stack.imgur.com/F1g3T.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F1g3T.png" alt="enter image description here"></a></p>