-2

私はいくつかの列の数を取得するこのクエリを持っています

SELECT 
CONCAT(u.firstname,' ',u.lastname) AS 'agent',
COUNT(CASE WHEN pa.answer_text LIKE '%yes%' THEN pa.answer_id END) AS yes,
COUNT(CASE WHEN pa.answer_text LIKE '%no%' THEN pa.answer_id END) AS NO,
COUNT(CASE WHEN l2u.lead_status_id IN (4,5,8,39) THEN l2u.lead_id END) AS pending,
COUNT(CASE WHEN l2u.lead_status_id IN (7,14,43) THEN l2u.lead_id END) AS wrong_number,

ここに問題があります..これの正しい構文は何ですか

COUNT(pending + wrong_number + yes + NO) AS 'total'
FROM USER u, poll_votes pv, poll_answers pa, lead_to_user_original l2u

WHERE u.user_id = pv.user_id
AND pv.answer_id = pa.answer_id
AND l2u.lead_id = pv.vote_lead_id
AND (pa.answer_client_one = '869' OR pa.answer_client_two = '869')
AND pv.vote_date BETWEEN '2013-07-01 00:00:01' AND '2013-07-17 23:59:59'
GROUP BY u.user_id
4

2 に答える 2