I have a query that joins two tables :
select CAST(pvt.Year AS VARCHAR) as Year, pvt.Description as 'Description', [6],[1],
from (
select fre.*,ec.Description from stat.Table1 fre
left join stat.Table2 ec on ec.Code = fre.Table2Code
where Year = {{Year}} [[AND Variable = {{Variable}}]][[AND {{Description}}]]
) sr
PIVOT
(
Max(Weighted_Avg) FOR [Variable] IN ([6],[1],)
) pvt
order by pvt.Year
I want a variable with 'Field to map to' but when i try to do so it gives this error :
The multi-part identifier "stat.Table2.Description" could not be bound.