Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要为一组值创建一个过程,例如。{1,2,3,3,3,3,4,5} 在我的表(x)中,字段名称是(y)我需要获得集合中最频繁的值,即(3)。如何执行此操作?
我已经尝试过,select MODE(y) from x 但我收到错误无效的函数名称
select MODE(y) from x
要计算模式,请使用此语句
SELECT TOP 1 "y" FROM x WHERE "y" IS Not NULL GROUP BY "y" ORDER BY COUNT(*) DESC
请检查以下 SQL Select 语句
select top 1 distinct y from x order by count(*) over (partition by y) desc
如果您想查看重复计数,也可以使用以下内容
select top 1 distinct y, count(*) over (partition by y) cnt from x order by cnt desc
我希望它有所帮助,