하위 쿼리를 사용하여 카운트 (*)를 작성하려면 어떻게해야합니까? (select * from Firms)
== Firms
되지하위 쿼리에서 카운트 (*)하는 방법
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ')'.
그러나 : 위의 두 줄에서
select count(*) from Firms
select count(*) from (select * from Firms)
, 상단 하나는 작동하지만 두 번째 줄에, 나는 오류가?
편집 : 이것에 대한 그러나 :
The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.
가 어떻게이 문제를 해결할 수 있습니다
select count(*) from
(
select HireResponseID, HireResponse, DateResponse, Comments, YearFileOpened, file_number, isCaseOpen, last_update, isConfidential, date_created, OurClient, TheirClient, ProjectName, description, lawyer_lastname, lawyer_firstname, Conflicts.ConflictID
from Hire_Response, Conflicts, Lawyers
WHERE Hire_Response.ConflictID=Conflicts.ConflictID AND Lawyers.lawyerID=Conflicts.lawyerID AND firmID = @FirmID AND HireID = @HireID AND isStillaConflict = 1
ORDER BY file_number, TheirClient, OurClient, lawyer_lastname, lawyer_firstname
) as data
내가 오류가? 당신은 두 번째 버전에 별칭을 누락
뿐만 아니라 하위 쿼리에 잘못된 order by 절은, 그것이 같으면이다 유용한 것을 이루지 못한다. –