--- ---Pedidos facturados --- select a.* from tbl_pedcab a with (nolock) inner join tbldoc b with (nolock) on b.strCamGen = a.strCamGen and b.strCodCA = a.strCodTer and b.strTipDoc = 'fc' where a.strCamGen = '201909' and b.strNumDoc is not null