操作数应包含 1 列

Operand should contain 1 column(s)

所以我正在尝试编写一个 SQL 语句如下...

I need to Find a list of artist names, the number of CDs they have produced, and the average price for their CDs. Only returning results for artists with more than one CD.

问题是每次我认为我得到它时,我都会收到一个错误读取 "Operand should contain 1 column(s)",我觉得我现在非常密集,但如果有人能提供帮助,我将不胜感激。

这是我上次试过的代码..

SELECT Artist.artID, CD.cdPrice, Count(*)
FROM CD
INNER JOIN Artist
ON Artist.artID=(SELECT CD.artID, AVG(CD.cdPrice), COUNT(*)
                 as Count FROM CD GROUP BY CD.artID HAVING Count > 1)

您的联接在右侧有三列 所以你可以使用像

这样的东西
SELECT Artist.artID, CD.cdPrice, Count(*)
FROM CD
INNER JOIN Artist
ON Artist.artID=(SELECT CD.artID
                 FROM CD 
                 GROUP BY CD.artID 
                 HAVING Count(*) > 1)
Group by Artist.artID, CD.cdPrice

备选方案

SELECT Artist.artID, CD.cdPrice, Count(*)
FROM CD
INNER JOIN Artist
ON Artist.artID=CD.artID
Group by Artist.artID, CD.cdPrice

备选方案 2

SELECT Artist.artID, AVG(CD.cdPrice), Count(*)
FROM CD
INNER JOIN Artist
ON Artist.artID=CD.artID
Group by Artist.artID
Having count(*) >1

你说的是WHERE artID= three columns就是这个问题