Q:

SQL: Report instances where only one of two possible value exists

I'm stuck trying to figure this out...
I have two data sets.
security_account.name and spot.format.
I need to find out which accounts ONLY contain spots with values of 'SD'.
This query:
select distinct
sa.name as "Sender Account"
from
security_account sa,
spot s
where
sa.id = s.provider_account_id
and s.format = 'SD';

Gives me a list of every account that has an SD spot, if I say != 'HD', I get the same results. Most accounts have HD and SD, I only want to see the accounts that ONLY CONTAIN SD in the spot table.
Any ideas?
Thank You, Matt.

A:

Use except.
select sa.name as "Sender Account"
from security_account sa
join spot s on sa.id = s.provider_account_id
where s.format = 'SD'
except
select sa.name as "Sender Account"
from security_account sa
join spot s on sa.id = s.provider_account_id
where s.format <> 'SD'

