Counting miss matches

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have two tables and in each table there is a primary key. Table A has
property state and Table B has QTM_State and I want a count on another field
that will count the miss matches of both. So for example:

TABLE A TABLE B
PK propertystate PK QTM_state
count
123 TX 123 VA
1
167 WA 167 WA
0
135 CA 135 CO
1
 
SELECT [TABLE A].PK, IIf([TABLE A].[propertystate]=[TABLE
B].[QTM_state],0,1) AS Mismatch
FROM [TABLE A] INNER JOIN [TABLE B] ON [TABLE A].PK = [TABLE A].PK;
 
Put the following in a query and run it. It will give you all the rows
where the State fields are not equal.

Select TableA.PK, propertystate, QTM_State
From TableA Inner Join TableB ON TableA.PK = TableB.PK
Where propertystate <> QTM_State

Hope that helps!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top