我有一个字段的数据类型设置为浮动的表.给定记录集的值应该给出1的总和,并且select中的字段返回1但是,HAVING子句另有说明.
以下是我在表格中的确切值,正如您所看到的,此示例执行相同的操作.为什么总和超过1?我搞不清楚了!
with example as (
SELECT 'Code' as Code, cast(0.462 as float) as perc
UNION ALL
SELECT 'Code' as Code, cast(0.116 as float) as perc
UNION ALL
SELECT 'Code' as Code, cast(0.181 as float) as perc
UNION ALL
SELECT 'Code' as Code, cast(0.053 as float) as perc
UNION ALL
SELECT 'Code' as Code, cast(0.188 as float) as perc
)
SELECT
Code,
SUM(perc)
FROM
example
GROUP BY Code
HAVING SUM(perc) > 1
Run Code Online (Sandbox Code Playgroud)