select a.num_oc,a.tipo,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec, a.cantidad,a.precio FROM cotb00015 a,cotb00014 c WHERE a.status_t is null and c.num_oc = a.num_oc and c.fech_oc between "010197" and "110897" and c.cierre = 'N' GROUP BY 1,2,3,4,5,6,7,8 ORDER BY 3,4,5,6,1