您好这个查询我正在尝试在 MySQL 中运行以在我的 ID 上获得良好的分布,但看起来语法上有一些问题。
select min(ID), max(ID),count(*), nt from ( select ID, ntile(16) over (order by ID) nt from table) group by nt order by nt;
这在 Oracle 中有效,但不是 MySQL,可能看起来它在 MySQL 5.7 中不可用。我们还能如何获得这些数据?
基本上我有生成的 UUID 应用程序,可以订购,需要组织和分组,然后分成 16 段。
预期产出
MIN(ID) MAX(ID) COUNT(*) NT
00000000-ebc5-4d19-9d7b 0a360b83-6d9a-17d7-9b67 36282227 1
0a360b83-6d9a-17d7-9b67 0a360b85-6ebb-1bbc-9bbb 36282227 2