Counting non duplicates between 2 columns Suppose we have two columns: Start &amp; End.
Both columns store an integer id.

For each id in the Start column, I want to be able to determine whether the same id exists in the End column. If not, the count should increment by 1.

How can this be done?
Should be fairly simple:

SELECT COUNT(DISTINCT a.Start) 
FROM TableName a
LEFT OUTER JOIN TableName b ON a.Start = b.End
WHERE b.Start IS NULL