我的 sql 有问题。我尝试在我的声明中将最大数量总和设为一行,但它不起作用。警告消息在 ')' 附近显示不正确的语法。这是我的代码:-
select sum(A) from (select t.ticketid, lt.description ticketsource,
c.description tickedcreted,
max_score = isnull(
(select max(si.marks) as max_score
from survey_items si
left join survey_questions sq on (si.question_id = sq.question_id)
left join survey s on (sq.survey_id = s.survey_id
and s.code_interaction= 1)),0
),
sum(si.marks) totalAnswer,
count(t.ticketid) totalticketcreated,
count(t.feedback) totalfeedbackreceived
from survey_items si
left join lookup_questions lq on (si.item_id = lq.item_id)
left join feedback fb on (fb.feedback_id = lq.feedback_id)
left join ticket t on (t.ticketid = fb.ticketid)
left join survey_questions sq on (si.question_id = sq.question_id)
left join survey s on (sq.survey_id = s.survey_id)
left join lookup_assignedOfficer c on (c.code = t.enteredby )
left join lookup_department ld on t.department_code =ld.code
left join lookup_ticketsource lt on lt.code = s.code_interaction
where t.trashed_date is null and lt.enabled =1 and ld.description is not null
and
((t.assigned_date BETWEEN '7/16/2012' AND '7/16/2012'))
)