create or replace function basics(n) as table ( select n, avg(x), stddev_pop(x), stddev_samp(x) from (select random() as x from range(0,n)) ); from basics(100) union all from basics(1000) union all from basics(10000) union all from basics(1000000000); with cte as (select random() as x from range(0,100)) from histogram(cte, x) ;