March 30, 2015 at 4:37 pm
I am trying to create a query where I use ISNULL once with the first select statement and than use cross apply to create the column I really want, however I am getting a error message of 102 from SQL Server 2014. It says I am using the incorrect syntax.
SELECT ISNULL(dbo.merica.Country,dbo.current_year.[Mega Region]) AS TEST
FROM dbo.current_year
CROSS APPLY (ISNULL(dbo.region_scorecard.[GAM Customer for Scorecard], TEST) AS [Regions/GAM])
LEFT OUTER JOIN
dbo.merica ON dbo.current_year.[Mega Region] = dbo.merica.Country
Thanks for your help.
March 31, 2015 at 1:29 am
It looks like dbo.region_scorecard is a table or a view.
In that case, you need to provide a predicate to correlate the table dbo.current_year with it:
SELECT ISNULL(dbo.merica.Country, dbo.current_year.[Mega Region]) AS TEST
FROM dbo.current_year
CROSS APPLY (
SELECT ISNULL(dbo.region_scorecard.[GAM Customer for Scorecard], TEST)
FROM dbo.region_scorecard
WHERE dbo.region_scorecard.PrimaryKey = dbo.current_year.SomeForeignKey
) AS [Regions/GAM]
LEFT OUTER JOIN dbo.merica
ON dbo.current_year.[Mega Region] = dbo.merica.Country
I can't see your database definition, so it's just guesses. If you want precise answers, post more information.
-- Gianluca Sartori
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply