Please take a look at this and tell me why this line
year(a.Date_Return) = b.Rpt_Year
gets this error:
Server: Msg 170, Level 15, State 1, Line 27
Line 27: Incorrect syntax near '.'.
select
a.Model_No,
year(a.Date_Return) as Rpt_Year,
a.Defect_Code,
count(*) as DefectCount,
max(b.TotalDefectCountForModel)
from
Returns_Analyzed a
inner join
(
select
Model_No,
year(Date_Return) as Rpt_Year,
count(*) as TotalDefectCountForModel
from
Returns_Analyzed
where
Defect_Code is not null and
Model_No is not null and
(isnull(Date_Return,'18990101') >= '1/1/2006' and isnull(Date_Return,'18990101') <= '1/31/2008')
group by
Model_No,
year(Date_Return)
) b
on
a.Model_No = b.Model_No,
year(a.Date_Return) = b.Rpt_Year
where
a.Defect_Code is not null and
a.Model_No is not null and
(isnull(Date_Return,'18990101') >= '1/1/2006' and isnull(Date_Return,'18990101') <= '1/31/2008')
group by
a.Model_No,
a.Defect_Code,
year(a.Date_Return)
order by
a.Model_No,
year(a.Date_Return)
year(a.Date_Return) = b.Rpt_Year
gets this error:
Server: Msg 170, Level 15, State 1, Line 27
Line 27: Incorrect syntax near '.'.
select
a.Model_No,
year(a.Date_Return) as Rpt_Year,
a.Defect_Code,
count(*) as DefectCount,
max(b.TotalDefectCountForModel)
from
Returns_Analyzed a
inner join
(
select
Model_No,
year(Date_Return) as Rpt_Year,
count(*) as TotalDefectCountForModel
from
Returns_Analyzed
where
Defect_Code is not null and
Model_No is not null and
(isnull(Date_Return,'18990101') >= '1/1/2006' and isnull(Date_Return,'18990101') <= '1/31/2008')
group by
Model_No,
year(Date_Return)
) b
on
a.Model_No = b.Model_No,
year(a.Date_Return) = b.Rpt_Year
where
a.Defect_Code is not null and
a.Model_No is not null and
(isnull(Date_Return,'18990101') >= '1/1/2006' and isnull(Date_Return,'18990101') <= '1/31/2008')
group by
a.Model_No,
a.Defect_Code,
year(a.Date_Return)
order by
a.Model_No,
year(a.Date_Return)