Try the following:
CASE WHEN table3.col3 IS NULL THEN table2.col3 ELSE table3.col3 END as col4
as col4
should go at the end of the CASE statement. Also note that you also lack END
.
Another, possibly simpler option:
IIf([table3.col3] Is Null,[table2.col3],[table3.col3])
To clarify, MS Access does not support COALESCE. If that would be the best way.
Change after a radical change in the question:
To rotate a query in SQL Server, you can use COALESCE (so this has been technically answered before):
SELECT dbo.AdminID.CountryID, dbo.AdminID.CountryName, dbo.AdminID.RegionID, dbo.AdminID.[Region name], dbo.AdminID.DistrictID, dbo.AdminID.DistrictName, dbo.AdminID.ADMIN3_ID, dbo.AdminID.ADMIN3, COALESCE(dbo.EU_Admin3.EUID, dbo.EU_Admin2.EUID) FROM dbo.AdminID
By the way, your CASE statement was missing before ,
before the field. That is why it did not work.
source share