Reputation: 5326
Rather than manually going through millions of records, is there a way to find the records which has difference in two amount columns? Is there a query to do it for me?
For example, Table A contains ColA and ColB with amountss on this and the datatype is "Money" on both columns. There are few instances where values are different (It's decimal values, apparently, yeah? Yes, because its money field).
Can somebo0dy help me with a query to extract the rows with difference in money values?
Upvotes: 0
Views: 90
Reputation: 10274
To consider rows where ColA or ColB are null you can write as:
select ColA, ColB
from TableA
where Isnull(ColA,0) - Isnull(ColB ,0) != 0
Upvotes: 1
Reputation: 180
In general, you can query rows having some conditions using where clause.
Select * from Table where Column1 operator Column2
So, here you can write:
Select * from TableA where ColA <> ColB
Upvotes: 0
Reputation: 3492
As both are same datatype. You just need to check ColA <> ColB.
SELECT * FROM TableA WHERE ColA <> ColB
Upvotes: 2