The query below looks at two existing tables, and based on the "Geography" column in each, it adds a "ReportType" column that tells you whether you're looking at National or Local data. The first part of the query works fine, but the second part is producing hundreds of blanks rows with "Local" in the ReportType column. I can't figure out why, because nat_tv.Geography only has "National"...there shouldn't be any "Local" data in it. Any ideas? I'm wondering if my IIf logic is faulty...
Code:
SELECT IIf(loc_tv.Geography="National","National","Local") AS ReportType, loc_tv.Geography, loc_tv.Indication, loc_tv.[Variable Name], loc_tv.[Variable Value]
FROM Localization_NatTV AS loc_tv
UNION ALL SELECT IIf(nat_tv.Geography="National","National","Local") AS ReportType, nat_tv.Geography, nat_tv.Indication, nat_tv.[Variable Name], nat_tv.[Variable Value]
FROM data_TVNational AS nat_tv;