C# 从SQL查询生成美元金额输出

C# 从SQL查询生成美元金额输出,c#,mysql,sql,sql-server,pattern-matching,C#,Mysql,Sql,Sql Server,Pattern Matching,我需要帮助生成一个美元金额,其中有瓜尔责任表、瓜尔总额表和Rem余额表。现在,它产生了一个十进制的数字,员工很难读懂。在SQL语言中,您将在何处添加以仅提取$amount?任何帮助都将不胜感激。SQL查询是: select top 10 b.date_of_service as DOS ,b.GUARANTOR_ID as Guarantor ,b.service_status_value as [Status] ,b

我需要帮助生成一个美元金额,其中有瓜尔责任表、瓜尔总额表和Rem余额表。现在,它产生了一个十进制的数字,员工很难读懂。在SQL语言中,您将在何处添加以仅提取$amount?任何帮助都将不胜感激。SQL查询是:

select top 10 b.date_of_service as DOS
             ,b.GUARANTOR_ID as Guarantor
             ,b.service_status_value as [Status]
             ,b.guarantor_liability as [Guar Liability]
             ,b.guarantor_total_payments as [Guar Total Payments]
             ,b.remaining_balance as [Rem Balance]
             ,b.CLAIM_NUMBER as [Claim #]
from SYSTEM.billing_tx_charge_detail b
where(b.GUARANTOR_ID = "100")
     or (b.GUARANTOR_ID = "110")
     or (b.GUARANTOR_ID = "111")
     or (b.GUARANTOR_ID = "112")
     or (b.GUARANTOR_ID = "113")
     or (b.GUARANTOR_ID = "114")
     or (b.GUARANTOR_ID = "115")
     or (b.GUARANTOR_ID = "119")
     and (b.FACILITY = ?FACILITY)
     and (b.PATID = ?PATID)
order by b.date_of_service desc;

您可以尝试使用FLOOR将结果向下舍入到最接近的整数。像这样的

select top 10 b.date_of_service as DOS
             ,b.GUARANTOR_ID as Guarantor
             ,b.service_status_value as [Status]
             ,FLOOR(b.guarantor_liability) as [Guar Liability]
             ,b.guarantor_total_payments as [Guar Total Payments]
             ,b.remaining_balance as [Rem Balance]
             ,b.CLAIM_NUMBER as [Claim #]
from SYSTEM.billing_tx_charge_detail b
where(b.GUARANTOR_ID = "100")
     or (b.GUARANTOR_ID = "110")
     or (b.GUARANTOR_ID = "111")
     or (b.GUARANTOR_ID = "112")
     or (b.GUARANTOR_ID = "113")
     or (b.GUARANTOR_ID = "114")
     or (b.GUARANTOR_ID = "115")
     or (b.GUARANTOR_ID = "119")
     and (b.FACILITY = ?FACILITY)
     and (b.PATID = ?PATID)
order by b.date_of_service desc;

因此,您知道,由于当前编写了
where
子句,您的
以及
运算符将无法按您希望的方式工作。目前,任何带有担保人ID的记录都将被返回,无论它们是否与贷款
和PATID
匹配,感谢iamdave的澄清。因此,如果我想让值与Facility和patidy匹配,那么where子句应该放在哪里呢?您需要将希望作为一个块计算的每组逻辑比较放在它们自己的括号中。例如,
其中a=1和b=2或c=3将返回
c=3
中的所有记录,而不管
a
b
中的值。而
其中a=1和(b=2或c=3)
将只返回
a=1
b=2
c=3
中的行。在您的情况下,似乎您希望使用
其中b.ID In('100'、'110'、'111'、'112'、'113'、'114'、'115'、'119'))和b.FACILITY=?FACILITY和b.PATID=?PATID
,这将返回
担保人ID
在提供的列表中的任何记录,并且
FACILITYID
PATID
值都是正确的。可能重复的-Answer适用于任何数字类型,不一定是int。