【发布时间】:2021-05-28 01:53:52
【问题描述】:
【问题讨论】:
-
你为什么想要这样的输出,只是出于好奇,现实生活中的用例是什么?
标签: sql sql-server
【问题讨论】:
标签: sql sql-server
您可以使用窗口函数。在你的情况下,你有一个没有间隙的序列,所以你可以使用模算术:
select max(case when units % 10 = 1 then units end),
max(case when units % 10 = 2 then units end),
. . .
max(case when units % 10 = 0 then units end)
from t
group by ceiling(units / 10.0);
【讨论】: