Select c.id, c.doctype, c.beginsat from smcontracts c where not exists (select su.idsupplier from smsupplycase su, smspec sp, smspecco spc where su.article = sp.article and c.id = sp.docid and c.doctype = sp.doctype and spc.specitem = sp.specitem)
select t.id, t.createdat, t.clientindex from smdocuments t where t.doctype='CO'
select t.id, t.createdat, t.clientindex from smdocuments t where t.doctype='CO'