Following SQL query:
select * from er_101
where cd_relnaam IN (
select cd_relnaam
from er_101
group by cd_relnaam
having count(*) > 1)
AND ld_relopdrachtgever = '1'
Though I need to have that sub query also limits on ld_relopdrachtgever = '1'
How is that possible with an HAVING statement?
You can also use WHERE
in sub-query.
SELECT * FROM er_101
WHERE cd_relnaam IN (
SELECT cd_relnaam
FROM er_101
WHERE ld_relopdrachtgever = '1' <--You can add WHERE clause before GROUP BY
--^^^^^----
GROUP BY cd_relnaam
HAVING COUNT(*) > 1)
AND ld_relopdrachtgever = '1'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.