SELECT query combining two field ids
I'm looking to combine two fields (ids) in a query that correspond to two different lookup tables in the database. I have this so far:
SELECT e.id, e.name, r.id, r.name
FROM
(select isnull(ethnicity_id, 3), isnull(race_id, 7), count(eir.id) as total
from enrollment_info_real eir)
join ethnicity e on (e.id = eir.ethnicity_id)
join race r on (r.id = eir.race_id)
group by ethnicity_id, race_id
I would like the select isnull... query to get me a data set that does not have nulls and then be able to join the lookup tables based on this data set. Any ideas on how to fix this? I keep getting the error message:
Server: Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'join'.
Thanks
|