0
이 쿼리는 정상적으로 실행되지만 where 절을 마지막 부분을 제외한 모든 subselect에 추가하면 오류가 발생합니다. 예제와 오류가 아래에 나와 있습니다. 나는 다음과 같이이 오류를 생성 할 때 당신이 날이 구문 오류?구문 errow when added where 절에서 sub select
SELECT Getdate() AS PullTime,
(SELECT Min(sqlagentstatus)
FROM dbo.tracksqlagentstatus) AS SQLAgentStatus,
(SELECT Max(memorygrants)
FROM dbo.trackmemorygrants) AS MemoryGrants,
(SELECT Avg(pagelifeexpectancy)
FROM trackple) AS PLE,
(SELECT Avg(freepages)
FROM dbo.trackfreepages) AS FreePages,
(SELECT Avg(sqlprocesscpu)
FROM dbo.trackcpu
WHERE capturetime > Dateadd(minute, -5, Getdate()))AS CPU
를 해결하는 데 도움이 수 있습니까, 하위 쿼리의 일부에 where 절을 추가해야하지만. 이 오류를 해결하기 위해 내가 뭘 할 수 있는지 아십니까? 수신
SELECT Getdate() AS PullTime,
(SELECT Min(sqlagentstatus)
FROM dbo.tracksqlagentstatus) AS SQLAgentStatus,
(SELECT Max(memorygrants)
FROM dbo.trackmemorygrants) AS MemoryGrants,
(SELECT Avg(pagelifeexpectancy)
FROM trackple) AS PLE,
(SELECT Avg(freepages)
FROM dbo.trackfreepages) AS FreePages
WHERE capturetime > Dateadd(minute, -5, Getdate()),
(SELECT Avg(sqlprocesscpu)
FROM dbo.trackcpu
WHERE capturetime > Dateadd(minute, -5, Getdate())) AS CPU
오류 메시지 :
Msg 102, Level 15, State 1, Line 12
Incorrect syntax near ','.
Msg 156, Level 15, State 1, Line 15
Incorrect syntax near the keyword 'as'.
이 Microsoft SQL Server 데이터베이스입니다.