-1

我有这个 sql 语句:

SELECT inquiry_response, 
        inquiry_response_date, 
        date_initiated, 
        date_closed, 
        (select count(*) 
            from Inquiry_Responses 
            where InquiryID = 1 AND lawyerID = 1) as col1 
        (select count(*) 
            from Lawyers, Firms, Conflicts, Inquiries, Inquiry_Responses 
            where Conflicts.lawyerID=Lawyers.lawyerID and 
                Inquiry_Responses.lawyerID=Lawyers.lawyerID and 
                Inquiry_Responses.InquiryID=Inquiries.InquiryID and 
                Conflicts.firmID=Firms.firmID and 
                Conflicts.firmID IN 
                (select FirmID 
                    from WorkPeriod 
                    where InquiryID = 1) and 
                Inquiry_Responses.lawyerID= 1 and 
                Inquiries.InquiryID = 1 and 
                date_created between date_initiated and inquiry_response_date) as col2
from Inquiry_Responses, Inquiries 
WHERE Inquiries.InquiryID = Inquiry_Responses.InquiryID AND Inquiry_Responses.InquiryID = 1 AND lawyerID = 1

我收到语法错误:

Msg 156, Level 15, State 1, Line 20
Incorrect syntax near the keyword 'as'.

有谁知道为什么会这样?

注意: 1 值实际上是参数变量,但我稍后会填写。

谢谢。

4

1 回答 1

4

在此处添加逗号:

(select count(*) 
            from Inquiry_Responses 
            where InquiryID = 1 AND lawyerID = 1) as col1,
                                                         ^ Here!
于 2013-05-21T20:28:58.800 回答