I need to select individual contacts with 1 status.
The problem is that a single contact can have multiple simultaneous statuses based on 4 distinct columns.
Active status supersedes inactive. If a contact has active and inactive status at the same time, it should default to active.
So far my sub queries work well independently but they return more than 1 value when a single contact has 2 or more simultaneous statuses in different columns.
Any ideas on how to return a single contact with 1 status?
SELECT Contact,
((SELECT 'Active'
FROM MyTable
WHERE Column1 = 1
OR Column2 = 1)
UNION
(SELECT 'Inactive'
FROM MyTable
WHERE Column3 = 1
OR Column4 = 1)) AS MyStatus
FROM MyTable
Have you considered using CASE instead?