When I execute the folowing query :
SELECT DISTINCT
dat.FiscalYear,
dat.MonthName As FiscalMonth,
dat.FiscalQuarter,
dat.FiscalSemester,
a.m AS m,
o.oName AS o,
o.Calculation,
o.oDispOrder ,
o.oGrpId
FROM
[V].[dbo].[DimDate] dat
CROSS JOIN
(SELECT
cal.calculation, ltrim(p.oName) As oName,
p.DisplayingOrder as oDispOrder, p.oGrpId
FROM
[V].[dbo].[Reporto] p
CROSS JOIN
(SELECT 'Year to Date' as Calculation
UNION
SELECT 'Current Dim Date' as Calculation
UNION
SELECT 'Previous Year' as Calculation
UNION
SELECT 'Last Year Current Month' as Calculation) cal
CROSS JOIN
(SELECT
ltrim(b.m) As m, b.DisplayingOrder as mDispOrder,
b.Used as used
FROM
[V].[dbo].[ReportBusinessLine] b
WHERE b.used = 1) a
WHERE
(p.used = 1 and p.reportId = 1)) o
WHERE
dat.FiscalYear = 2013
I always got the following error :
Msg 4104, Level 16, State 1, Line 6
The multi-part identifier "a.m" could not be bound.
Many thanks .