当我尝试此查询时,
select
(A.StudentId),
max(A.StudentFirstName),
max(A.StudentLastName),
max(A.StudentAddress),
'Batch ' + max(C.BatchName),
CAST(MAX(CAST(A.StudentStatus as INT)) AS BIT),
max(B.StudentBatchId)
from
tblStudentDetails A
inner join
tblStudentBatchDetails B on A.StudentId = B.studentid
inner join
tblBatch C on C.BatchId = B.batchid
where
max(A.StudentFirstName) like 'A%'
group by
A.StudentId
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
除非聚集在HAVING子句或选择列表中包含的子查询中,并且聚集的列是外部引用,否则聚集可能不会出现在WHERE子句中。
有人可以帮助您解决此问题吗?