如果某个值超过3,我只想显示一行。 这是我的代码。
SELECT cursus_id
from cursussen
WHERE cursus_id IN(
SELECT cursussen.cursus_id
from cursussen
INNER JOIN inschrijvingen
ON cursussen.cursus_id=inschrijvingen.cursus_id
HAVING COUNT(cursussen.cursus_id) > 3
);
它只是一直给我同样的输出女巫是id。
我只想在桌面上显示超过3次的cursus_id。
请帮助我:D
答案 0 :(得分:0)
-2已经不知道这个网站有如此势利
答案 1 :(得分:0)
猜猜你想要这个:
SELECT c.cursus_id, COUNT(*) AS count
FROM cursussen c
INNER JOIN inschrijvingen i
ON c.cursus_id = i.cursus_id
GROUP BY c.cursus_id
HAVING count > 3;
或
SELECT id FROM (
SELECT c.cursus_id AS id, COUNT(*) AS count
FROM cursussen c
INNER JOIN inschrijvingen i
ON c.cursus_id = i.cursus_id
GROUP BY c.cursus_id
HAVING count > 3;
) t;