SQL Server编程的新手,想查看我是否可以获得有关此查询的帮助。 说我有LatencyInfo自定义聚合函数或sql server中的等价物
DateTime Latency
2014-01-21 00:00:00 12334
2014-01-21 00:00:00 56384
2014-01-20 00:00:00 1232
2014-01-20 00:00:00 4353
2014-01-19 00:00:00 434343
我的目标是要找到95个百分点的延迟时间为每天的查询表。所以,我能够拿出第95个百分点作为单一日期,但我坚持将它聚合到日期上。我无法使用PERCENTILE-CONT,因为我所碰到的sql server版本不支持此查询。
select MIN(P.latency)
from
(select top 5 PERCENT S.latency as PerLatencyInfo
from
(select convert(varchar(20), datetimefield, 1) as datefield
,latency
from LatencyInfo
where datetimefield >= '2014-01-21 00:00:00'
) as S
order by S.latency DESC
) as P
任何帮助非常感谢它。我无法在这里尝试CLR聚合,因为我无法在服务器上安装.NET框架。
如果我不能使用自定义聚合函数,即使我可以得到任何其他等效逻辑的帮助,它会很好。
使用SQL Server 11.0.9
您使用的是哪个版本的SQL Server? – NickyvV
[[计算第95个百分点值?](http://stackoverflow.com/questions/6784299/calculating-the-95th-percentile-value)]这里提供了[Oracle的PERCENTILE_CONT实现使用SQL Server 2005分析函数的链接](http://blogs.msdn.com/b/sqltips/archive/2006/05/15/598372.aspx)文章。 –
使用Sql Server 11.0.9206 – user3167619