【发布时间】:2010-08-23 20:00:33
【问题描述】:
使用 SQL Server 2000 是否有更简单/更清洁的方法来执行此操作?
每隔几天我就需要这样做。
我先看看我们总共有多少条记录:
SELECT COUNT(*) FROM MyTable
然后我列出某个字段的所有长度:
SELECT LEN(MyText)
FROM MyTable
ORDER BY LEN(MyText) ASC
然后我需要向下滚动 1/3... 并记下值。 然后我需要向下滚动 2/3... 并记下值。 最后是最后一个值。
我需要找出 x、y 和 z:
33% of the records have this field with a length under x bytes
66% of the records have this field with a length under y bytes
100% of the records have this field with a length under z bytes
【问题讨论】:
-
您是否有没有中断的标识列?如果你这样做(或可以加一个),然后得到总数并除以 3。
标签: sql sql-server sorting sql-order-by ranking