2
我有以下SQL命令:SQL COUNT FORM連接表
SELECT "USERNAME"."TOPICS".VALUE,
"USERNAME"."TOPICS".QID,
"USERNAME"."QUESTION".QRATING
FROM "USERNAME"."TOPICS" JOIN "USERNAME"."QUESTION"
ON "USERNAME"."TOPICS".QID = "USERNAME"."QUESTION".QID
AND "USERNAME"."TOPICS".VALUE = 'kia'
ORDER BY QRATING DESC
它的作品真的很好,但我想看看有多少元素的回報。於是,我就用:
SELECT COUNT("USERNAME"."TOPICS".QID)
FROM "USERNAME"."TOPICS" JOIN "USERNAME"."QUESTION"
ON "USERNAME"."TOPICS".QID = "USERNAME"."QUESTION".QID
AND "USERNAME"."TOPICS".VALUE = 'kia'
ORDER BY QRATING DESC
但我得到的錯誤:
列引用 'USERNAME.TOPICS.VALUE' 是無效的。當SELECT 列表包含至少一個聚合時,則所有條目必須有效 聚合表達式。
什麼問題?