0

您好,我有以下查询:其中显示 [Enquete Vraag] = enquete_vraag 我试图将其作为子查询:

[Enquete Vraag] = 
(
 SELECT enquete_vraag
 FROM enquete_vraag
)

因为 enquete_vraag 中有多行,所以我收到以下错误:

子查询返回超过 1 个值。当子查询跟随 =、!=、<、<=、>、>= 或子查询用作表达式时,这是不允许的。

我需要的是显示 enquete_vraag 中的所有行。

SELECT  d.docent, 
    v.vak,
    [Enquete Vraag] = enquete_vraag,
    [Totaal Aantal Studenten] = 
        (
        SELECT COUNT(student_ID) 
        FROM student 
        LEFT JOIN klas
        ON student.klas_ID = klas.klas_ID
        INNER JOIN kdv
        ON klas.klas_ID = kdv.klas_ID
        INNER JOIN docent
        ON kdv.docent_ID = docent.docent_ID
        INNER JOIN vak
        ON kdv.vak_ID = vak.vak_ID
        WHERE docent.docent_ID = '1158'
        AND vak.vak_ID = '449'
        ),
    [Totaal Aantal Studenten Enquete Ingevuld] = 
        (
        SELECT COUNT(enquete_antwoord_ID) 
        FROM enquete_antwoord
        INNER JOIN kdv
        ON enquete_antwoord.kdv_ID = kdv.kdv_ID
        INNER JOIN vak
        ON kdv.vak_ID = vak.vak_ID
        INNER JOIN docent
        ON kdv.docent_ID = docent.docent_ID
        WHERE docent.docent_ID = '1158'
        AND vak.vak_ID = '449'
        ), 
    [Gemiddelde Antwoord] = 
        (
        SELECT AVG(enquete_antwoord_radio)
        FROM enquete_antwoord
        INNER JOIN KDV
        ON enquete_antwoord.kdv_ID = kdv.kdv_ID
        INNER JOIN vak
        ON kdv.vak_ID = vak.vak_ID
        INNER JOIN docent
        ON kdv.docent_ID = docent.docent_ID
        WHERE docent.docent_ID = '1158'
        AND vak.vak_ID = '449'
        )
    FROM    enquete_vraag ev
    LEFT JOIN enquete_antwoord ea
        ON  ea.enquete_vraag_ID = ev.enquete_vraag_ID
    LEFT JOIN kdv
        ON ea.kdv_ID = kdv.kdv_ID
    INNER JOIN klas k
        ON kdv.klas_ID = k.klas_ID
    INNER JOIN vak v
        ON kdv.vak_ID = v.vak_ID
    INNER JOIN docent d
        ON kdv.docent_ID = d.docent_ID
    LEFT JOIN student s
        ON k.klas_ID = s.klas_ID
   WHERE   d.docent_ID = '1158' 
   AND     v.vak_ID = '449'
   GROUP BY v.vak, d.docent, ev.enquete_vraag; 

通过此查询,我得到以下输出:

docent.........   vak ................. vraag...........studenten......aantal...gemiddeld

Dhr,...........   Linux praktijk....... QUESTION1...... 83............. 2........7

我真正需要的是这个:

docent.........   vak ................. vraag...........studenten......aantal...gemiddeld

Dhr,............  Linux praktijk....... QUESTION2...... 83.............0.........0

我真的希望有人可以帮助我,我整个早上都在努力解决这个问题。谢谢

4

0 回答 0