sql quer


SELECT
(SELECT COUNT (sysid)
FROM FwInvConsumable
WHERE parentref = g.sysid
AND (ns.state = 'Inventory' OR ns.state = 'Qualification')),

(SELECT COUNT (ns.sysid)
FROM FwInvConsumable ns--,FWINVCONSUMABLEGROUP g
WHERE ns.parentref = g.sysid)
FROM FWINVCONSUMABLEGROUP g, FwInvConsumable ns

where (select count(sysid) from FwInvConsumable where parentref = g.sysid and (ns.state = 'Inventory' or ns.state = 'Qualification')) = " +
" (select count(ns.sysid) from FwInvConsumable ns,FwInvConsumableGroup g where ns.parentref = g.sysid)";

SELECT ID, partnumber, partrevision
FROM fwinvconsumablegroup
WHERE (SELECT COUNT (sysid)
FROM fwinvconsumable
WHERE parentref = fwinvconsumablegroup.sysid
AND state <> 'Terminated') = 0

原文地址:https://www.cnblogs.com/newcoder/p/5103249.html