I have 2 different columns in 2 tables, one is with Money datatype in table1 and another one with Decimal(13,4) in table2.I need to sum values in table2 and compare it with value in table1(HAmount).
However i found values like below, please suggest how to compare this.
Table1
HAmount
120.4500
Table2
DAmount
60.2285
60.2200
IF(HAmount=SUM(DAmount))
BEGIN
Success
END
ELSE
Failed
Just convert everything to
DECIMAL (13,2):IF(CAST(HAmount as DECIMAL(13,2) = SUM(CAST(DAmount as DECIMAL(13,2)))With default rounding settings this should give you the desired output without having to factor in “behind-the-scenes” decimals that aren’t displayed.