【Oracle】SQL 将一组已经排序的数据进行分组,按照每组50行进行分组
简单来说,使用ceil函数
SELECT
your_column,
--ROW_NUMBER() OVER (ORDER BY your_column) 为排序的开窗函数,用那种都可以
CEIL(ROW_NUMBER() OVER (ORDER BY your_column) / 51) AS group_number
FROM
your_table;
示例:
select distinct t.aa,
t.cc,
dense_rank() over(partition by t.cc order by t.aa) as tt,
ceil(dense_rank() over(partition by t.cc order by t.aa) / 50) AS group_number
from table_name t