でグループIは私が一つに結合したい3つのSELECTステートメントがあります。は1つのクエリに複数のカウントを組み合わせる -
SELECT COUNT(A.id), CONCAT(B.fname,' ', B.lname) AS fullname
FROM feedbacks A
INNER JOIN users B
ON A.userid = B.userid
WHERE DATE(origindate) BETWEEN '2011-03-01' AND '2011-07-11'
GROUP BY fullname
SELECT COUNT(A.id), CONCAT(B.fname,' ', B.lname) AS fullname
FROM feedbacks A
INNER JOIN users B
ON A.userid = B.userid
WHERE status = 'C'
AND DATE(origindate) BETWEEN '2011-03-01' AND '2011-07-11'
GROUP BY fullname`
SELECT COUNT(A.id), CONCAT(B.fname,' ', B.lname) AS fullname
FROM feedbacks A
INNER JOIN users B ON A.userid = B.userid
WHERE caused_change = 1
AND DATE(origindate) BETWEEN '2011-03-01' AND '2011-07-11'
GROUP BY fullname
しかし、それらを組み合わせることで、常にエラーを返すように思われる:(オペランドが1列が含まれている必要があります( S))
SELECT
(SELECT COUNT(A.id), CONCAT(B.fname,' ', B.lname) AS fullname FROM feedbacks A INNER JOIN users B ON A.userid = B.userid WHERE DATE(origindate) BETWEEN '2011-03-01' AND '2011-07-11' GROUP BY fullname) AS T1,
(SELECT COUNT(A.id), CONCAT(B.fname,' ', B.lname) AS fullname FROM feedbacks A INNER JOIN users B ON A.userid = B.userid WHERE status = 'C' AND DATE(origindate) BETWEEN '2011-03-01' AND '2011-07-11' GROUP BY fullname) AS T2,
(SELECT COUNT(A.id), CONCAT(B.fname,' ', B.lname) AS fullname FROM feedbacks A INNER JOIN users B ON A.userid = B.userid WHERE caused_change = 1 AND DATE(origindate) BETWEEN '2011-03-01' AND '2011-07-11' GROUP BY fullname) AS T3
だから私は作るために、個々の文からJOINとGROUPを削除しようとした:
SELECT CONCAT(B.fname, ' ', B.lname) AS fullname,
(SELECT COUNT(A.id) FROM feedbacks A WHERE DATE(origindate) BETWEEN '2011-03-01' AND '2011-07-11') AS T1,
(SELECT COUNT(A.id) FROM feedbacks A WHERE status = 'C' AND DATE(origindate) BETWEEN '2011-03-01' AND '2011-07-11') AS T2,
(SELECT COUNT(A.id) FROM feedbacks A WHERE caused_change = 1 AND DATE(origindate) BETWEEN '2011-03-01' AND '2011-07-11') AS T3
FROM feedbacks
INNER JOIN users B
ON feedbacks.userid = B.userid
GROUP BY fullname
しかしトン帽子は、ユーザーによるブレークダウンとカウントダウンとの合計を返します(countはwhere句のユーザーIDまたはフルネームについては何も言いませんが、間違いありません)。
私は近くにいるが、何かが足りないと感じる。誰かがここで正しい方向に向けることができますか?私はちょうど私が間違っていることを学ぼうとしています。
ありがとうございます。
ありがとう、Scorpi0(そして編集のために)。 – greatcaesarsghost
ありがとう!これは今日非常に役立つことが判明しました。 –
伝説の男たちは、今日私に深刻な時間を節約しました。乾杯!!。 – jiraiya