cr_do_ntile.sql
This page documents the preview version (v2.21). Preview includes features under active development and is for development and testing only. For production, use the stable version (v2024.1). To learn more, see Versioning.
Save this script as cr_do_ntile.sql
.
create or replace procedure do_ntile(no_of_buckets in int)
language sql
as $body$
insert into results(method, bucket, n, min_s, max_s)
with
ntiles as (
select
score,
(ntile(no_of_buckets) over w) as bucket
from t4_view
window w as (order by score))
select
'ntile',
bucket,
count(*),
min(score),
max(score)
from ntiles
group by bucket;
$body$;