SELECT LGS.Nivel1, LGS.Name_Nivel1, LGS.Nivel2, LGS.Name_Nivel2, LGS.Nivel3, LGS.Name_Nivel3, LGS.Nivel4, LGS.Name_Nivel4, VTA.Fecha, VTA.NroFactura, VTA.CodigoArticulo, VTA.CodigoArticulo+'-'+VTA.NameAlias as CodArt_Buscar, VTA.NameAlias, VTA.CodigoCliente, VTA.NombreCliente as CodCli_Buscar, VTA.NombreCliente, VTA.Segmento, VTA.LINEDISC, VTA.CustGroup, VTA.ciudad, VTA.Dpto, VTA.Zona, VTA.FormaPago, VTA.OrigenVenta, VTA.UnidNegocio, VTA.Sucursal as CodigoAlmacen, VTA.Sucursal, VTA.CodigoEmpleado, VTA.Nombres, VTA.Empresa, VTA.Regional, VTA.UnidMedida, VTA.Costo, VTA.cantidad, VTA.Importe, VTA.IVA, VTA.ImpNeto FROM RIBf_ventasclientes_cliven_ribe(@empresa,@fechaIni,@FechaFin) VTA LEFT JOIN RIBf_LGS_Items_Ribe(@empresa) as LGS ON VTA.CodigoArticulo=LGS.ITEMID AND VTA.Empresa=LGS.DataAreaId WHERE VTA.Empresa=@empresa AND VTA.Fecha>=@fechaIni AND VTA.fecha<=@FechaFin