Skip to content
Advertisement

How to compare records in a SQL Table

I have a table name TransactionTable. If InsuranceCode = ‘ADAP’ and IsADAP = 1, I have to filter these records and return the remaining records.

I am trying to write something similar to this syntax.

Total records in TransactionTable is 1832 and Total records on filtration criteria is 109. I expect 1723 records as output. Below syntax returns only 785 records. I am aware that below syntax is incorrect.

How to compare a table records and get the output.

Advertisement

Answer

This is probably what you want:

Lookup DeMorgan’s laws if you want to understand why.

Note that the above has the same meaning as this version: (disregarding NULLs)

.. which is because of DeMorgan’s laws.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement