SELECT n1.group_id
FROM
(SELECT grp.group_id, Count(grp.id_handle) AS Count_handle
FROM nic_handle INNER JOIN grp ON nic_handle.id_handle = grp.id_handle
WHERE nic_handle.nic_hande IN ('biz','host')
GROUP BY grp.group_id) AS n1
INNER JOIN
(SELECT grp.group_id, Count(grp.group_id) AS Count_group
FROM (SELECT grp.group_id, Count(grp.id_handle) AS Count_handle
FROM nic_handle INNER JOIN grp ON nic_handle.id_handle = grp.id_handle
WHERE nic_handle.nic_hande IN ('biz','host')
GROUP BY grp.group_id) AS n1 INNER JOIN grp ON n1.group_id = grp.group_id
GROUP BY grp.group_id) AS n2
ON (n1.Count_handle = n2.Count_group) AND (n1.group_id = n2.group_id)
WHERE ((n1.Count_handle=2));
|