Sql 如何查找小数点后两位以上的值?

Sql 如何查找小数点后两位以上的值?,sql,decimal,Sql,Decimal,我正在验证数据,并试图找出一列中是否有任何允许的值,其小数位数超过2位24.1145678234.444,-1234.09012 with t1 as ( select (allowed_amount - round(allowed_amount,2)) as ck from export_core_report_client_output where runid = '0c7c2d34-6cc3-43b0-ae4b-4bd8f4bddfb0' ) select min(ck) a

我正在验证数据,并试图找出一列中是否有任何允许的值,其小数位数超过2位24.1145678234.444,-1234.09012

with t1 as (
  select (allowed_amount - round(allowed_amount,2)) as ck
  from export_core_report_client_output
  where runid = '0c7c2d34-6cc3-43b0-ae4b-4bd8f4bddfb0'
) 
select min(ck) as min, max(ck) as max from t1

一种选择是使用以下公式:

SELECT
    num,
    CASE WHEN 100*num - CAST(100*num AS int) > 0 THEN 'yes' ELSE 'no' END AS field
FROM yourTable;
例如,对于值24.1234,上述公式计算:

2412.34 - 2412 = 0.34 > 0
但对于24.12,我们得到:


假设allowed_amount列是varchar或nvarchar,您可以使用Charindex来实现这一点

选择lensubstringallowed\u amount,charindex'',allowed\u amount+1,lenallowed\u amount from export\u core\u report\u client\u output

这将为您提供后面的十进制值计数,然后您可以在where子句中使用相同的语句进行仔细检查,如:

选择lensubstringallowed\u amount,charindex'',allowed\u amount+1,lenallowed\u amount from export\u core\u report\u client\u output 其中lensubstringallowed_amount,charindex'',allowed_amount+1,lenallowed_amount>2


评论中出现了任何问题

你能发布你试图用来完成这一任务的代码吗?t1作为选择允许金额-舍入允许金额,2作为导出核心报告客户机输出的ck,其中runid='0c7c2d34-6cc3-43b0-ae4b-4B8F4BDDFB0'从t1select中选择minck作为min,maxck作为max,其中舍入金额,2金额
2412 - 2412 = 0