Skip to main content
se añadieron 84 caracteres en el cuerpo
Origen Enlace
user75901
user75901

SELECT * FROM (SELECT a.NUM_ITM, a.NUM_CUO , b.NOM_CON,b.COD_CON,a.FEC_ITM,a.LIQ_ITM,a.ABO_CAP,a.VLR_ITM,a.PAGOS,a.EST_ITM FROM CUOTAS_ITEMS a RIGHT JOIN CONCEPTOS b ON a.COD_CON=b.COD_CON WHERE NUM_CUO IN (SELECT DISTINCT(NUM_CUO) FROM CUOTAS_ITEMS WHERE COD_EPL='OCAS02')
ORDER BY a.NUM_CUO) WHERE LIQ_ITM = 110 OR LIQ_ITM=153 OR LIQ_ITM = 111 OR LIQ_ITM=154 OR LIQ_ITM = 130 OR LIQ_ITM=230 AND NUM_CUO IN(

SELECT DISTINCT(NUM_CUO) FROM( SELECT MIN(NUM_ITM),NUM_CUO FROM( SELECT * FROM (SELECT a.NUM_ITM, a.NUM_CUO , b.NOM_CON,b.COD_CON,a.FEC_ITM,a.LIQ_ITM,a.ABO_CAP,a.VLR_ITM,a.PAGOS,a.EST_ITM FROM CUOTAS_ITEMS a RIGHT JOIN CONCEPTOS b ON a.COD_CON=b.COD_CON WHERE NUM_CUO IN (SELECT DISTINCT(NUM_CUO) FROM CUOTAS_ITEMS WHERE COD_EPL='OCAS02')
ORDER BY a.NUM_CUO) WHERE LIQ_ITM = 110 OR LIQ_ITM=153 OR LIQ_ITM = 111 OR LIQ_ITM=154 OR LIQ_ITM = 130 OR LIQ_ITM=230

SELECT *
FROM (SELECT a.NUM_ITM, a.NUM_CUO , b.NOM_CON,b.COD_CON,a.FEC_ITM,a.LIQ_ITM,a.ABO_CAP,a.VLR_ITM,a.PAGOS,a.EST_ITM
      FROM CUOTAS_ITEMS a RIGHT  JOIN CONCEPTOS b ON  a.COD_CON=b.COD_CON 
      WHERE NUM_CUO IN  (SELECT DISTINCT(NUM_CUO) FROM CUOTAS_ITEMS WHERE COD_EPL='OCAS02')  
      ORDER BY a.NUM_CUO) 
WHERE LIQ_ITM = 110 OR LIQ_ITM=153 OR LIQ_ITM = 111 OR LIQ_ITM=154 OR LIQ_ITM = 130 OR LIQ_ITM=230 
AND NUM_CUO IN(

SELECT DISTINCT(NUM_CUO) FROM(
 SELECT MIN(NUM_ITM),NUM_CUO  FROM(
   SELECT *
   FROM (SELECT a.NUM_ITM, a.NUM_CUO , b.NOM_CON,b.COD_CON,a.FEC_ITM,a.LIQ_ITM,a.ABO_CAP,a.VLR_ITM,a.PAGOS,a.EST_ITM
               FROM CUOTAS_ITEMS a RIGHT  JOIN CONCEPTOS b ON  a.COD_CON=b.COD_CON 
               WHERE NUM_CUO IN  (SELECT DISTINCT(NUM_CUO) FROM CUOTAS_ITEMS WHERE COD_EPL='OCAS02')  
               ORDER BY a.NUM_CUO) 
    WHERE LIQ_ITM = 110 OR LIQ_ITM=153 OR LIQ_ITM = 111 OR LIQ_ITM=154 OR LIQ_ITM = 130 OR LIQ_ITM=230
    
    ORDER BY NUM_ITM)
GROUP BY NUM_CUO
)
)

GROUP BY NUM_CUO ) )

SELECT * FROM (SELECT a.NUM_ITM, a.NUM_CUO , b.NOM_CON,b.COD_CON,a.FEC_ITM,a.LIQ_ITM,a.ABO_CAP,a.VLR_ITM,a.PAGOS,a.EST_ITM FROM CUOTAS_ITEMS a RIGHT JOIN CONCEPTOS b ON a.COD_CON=b.COD_CON WHERE NUM_CUO IN (SELECT DISTINCT(NUM_CUO) FROM CUOTAS_ITEMS WHERE COD_EPL='OCAS02')
ORDER BY a.NUM_CUO) WHERE LIQ_ITM = 110 OR LIQ_ITM=153 OR LIQ_ITM = 111 OR LIQ_ITM=154 OR LIQ_ITM = 130 OR LIQ_ITM=230 AND NUM_CUO IN(

SELECT DISTINCT(NUM_CUO) FROM( SELECT MIN(NUM_ITM),NUM_CUO FROM( SELECT * FROM (SELECT a.NUM_ITM, a.NUM_CUO , b.NOM_CON,b.COD_CON,a.FEC_ITM,a.LIQ_ITM,a.ABO_CAP,a.VLR_ITM,a.PAGOS,a.EST_ITM FROM CUOTAS_ITEMS a RIGHT JOIN CONCEPTOS b ON a.COD_CON=b.COD_CON WHERE NUM_CUO IN (SELECT DISTINCT(NUM_CUO) FROM CUOTAS_ITEMS WHERE COD_EPL='OCAS02')
ORDER BY a.NUM_CUO) WHERE LIQ_ITM = 110 OR LIQ_ITM=153 OR LIQ_ITM = 111 OR LIQ_ITM=154 OR LIQ_ITM = 130 OR LIQ_ITM=230

ORDER BY NUM_ITM)

GROUP BY NUM_CUO ) )

SELECT *
FROM (SELECT a.NUM_ITM, a.NUM_CUO , b.NOM_CON,b.COD_CON,a.FEC_ITM,a.LIQ_ITM,a.ABO_CAP,a.VLR_ITM,a.PAGOS,a.EST_ITM
      FROM CUOTAS_ITEMS a RIGHT  JOIN CONCEPTOS b ON  a.COD_CON=b.COD_CON 
      WHERE NUM_CUO IN  (SELECT DISTINCT(NUM_CUO) FROM CUOTAS_ITEMS WHERE COD_EPL='OCAS02')  
      ORDER BY a.NUM_CUO) 
WHERE LIQ_ITM = 110 OR LIQ_ITM=153 OR LIQ_ITM = 111 OR LIQ_ITM=154 OR LIQ_ITM = 130 OR LIQ_ITM=230 
AND NUM_CUO IN(

SELECT DISTINCT(NUM_CUO) FROM(
 SELECT MIN(NUM_ITM),NUM_CUO  FROM(
   SELECT *
   FROM (SELECT a.NUM_ITM, a.NUM_CUO , b.NOM_CON,b.COD_CON,a.FEC_ITM,a.LIQ_ITM,a.ABO_CAP,a.VLR_ITM,a.PAGOS,a.EST_ITM
               FROM CUOTAS_ITEMS a RIGHT  JOIN CONCEPTOS b ON  a.COD_CON=b.COD_CON 
               WHERE NUM_CUO IN  (SELECT DISTINCT(NUM_CUO) FROM CUOTAS_ITEMS WHERE COD_EPL='OCAS02')  
               ORDER BY a.NUM_CUO) 
    WHERE LIQ_ITM = 110 OR LIQ_ITM=153 OR LIQ_ITM = 111 OR LIQ_ITM=154 OR LIQ_ITM = 130 OR LIQ_ITM=230
    
    ORDER BY NUM_ITM)
GROUP BY NUM_CUO
)
)
Origen Enlace

Ayuda con una consulta de una tabla Oracle

estoy tratando de hacer un query de una tabla de registros de prestamos de dinero, tengo que implementar un query que me arroje al valor de ABO_CAP del préstamo con la fecha más mínima ; la columna NUM_CUO es la que me dice que préstamo en especifico tengo.He estado construyendo el query, y ya logre filtrar y traer los datos esenciales para esta consulta, mostrados en el siguiente pantallazo:

El query me arroja la siguiente consulta

Ahora el inconveniente es que no se como hacer para que me muestre solo un registro por NUM_CUO , trayendo solo el registro con la fecha mas mínima (Como esta me esta trayendo todas las fechas de los diferentes NUM_CUO). Por poner el ejemplo: del registro NUM_CUO 4770 que me muestre solo el registro que tiene la fecha 15/06/00; del registro 33945 que me muestre solo el registro que tiene la fecha 30/11/16. (Es decir de esta consulta solo me debe mostrar 3 filas).

A continuación les muestro como llevo el query armado:

SELECT * FROM (SELECT a.NUM_ITM, a.NUM_CUO , b.NOM_CON,b.COD_CON,a.FEC_ITM,a.LIQ_ITM,a.ABO_CAP,a.VLR_ITM,a.PAGOS,a.EST_ITM FROM CUOTAS_ITEMS a RIGHT JOIN CONCEPTOS b ON a.COD_CON=b.COD_CON WHERE NUM_CUO IN (SELECT DISTINCT(NUM_CUO) FROM CUOTAS_ITEMS WHERE COD_EPL='OCAS02')
ORDER BY a.NUM_CUO) WHERE LIQ_ITM = 110 OR LIQ_ITM=153 OR LIQ_ITM = 111 OR LIQ_ITM=154 OR LIQ_ITM = 130 OR LIQ_ITM=230 AND NUM_CUO IN(

SELECT DISTINCT(NUM_CUO) FROM( SELECT MIN(NUM_ITM),NUM_CUO FROM( SELECT * FROM (SELECT a.NUM_ITM, a.NUM_CUO , b.NOM_CON,b.COD_CON,a.FEC_ITM,a.LIQ_ITM,a.ABO_CAP,a.VLR_ITM,a.PAGOS,a.EST_ITM FROM CUOTAS_ITEMS a RIGHT JOIN CONCEPTOS b ON a.COD_CON=b.COD_CON WHERE NUM_CUO IN (SELECT DISTINCT(NUM_CUO) FROM CUOTAS_ITEMS WHERE COD_EPL='OCAS02')
ORDER BY a.NUM_CUO) WHERE LIQ_ITM = 110 OR LIQ_ITM=153 OR LIQ_ITM = 111 OR LIQ_ITM=154 OR LIQ_ITM = 130 OR LIQ_ITM=230

ORDER BY NUM_ITM)

GROUP BY NUM_CUO ) )

Agradecería mucho que me puedan colaborar, muchas gracias