Select 1 from aGroup a,aShift_Process h
Where
Not Exists(Select 1 from aCalendar i
Where
a.xCalendar = i.xCategory
And i.Term Between h.BeginDate and h.EndDate +1
Group By i.xCategory , DateDiff(day,h.BeginDate,h.EndDate) +2
Having Count(i.xCategory) = DateDiff(day,h.BeginDate,h.EndDate) +2
)
上面的脚本在SQL2000执行不报错,
到SQL2005或更高版本就报错:每个 GROUP BY 表达式必须至少包含一个不是外部引用的列。
除了重新写,有什么办法解决?