select quartile, max(id), min(id), count(*) from (
SELECT id, NTILE(10) OVER (ORDER BY id DESC)
AS quartile from tablename
) group by quartile
The above query will help you divide the number of record's into ten groups of equal size.
helpful when running procedures by range.
No comments:
Post a Comment