I have a query where I join a table on itself to find mismatches between a parts height or width. The only problem is that because of this join it will return each miss-match twice for each part. I only want to return one row for each miss-match, not two.
Here's the table:
tblTagGlass
JobID varchar
UnitCode varchar
PartCode varchar
PartQty int
TagHeight float
TagWidth float
and the query:
select *
from tblTagGlass ttg
inner join tblTagGlass ttgC ON
ttg.JobID = ttgC.JobID
AND ttg.PartCode = ttgC.PartCode
where ttg.TagHeight != ttgC.TagHeight
or ttg.TagWidth != ttgC.TagWidth
order by ttg.PartCode
and the results:
INC375 U2-052 VT2-011 1 2013 1444.5 INC375 U2-028 VT2-011 1 2012.5 1444.5
INC375 U2-028 VT2-011 1 2012.5 1444.5 INC375 U2-052 VT2-011 1 2013 1444.5
I hope this makes sense...