[Solved] Query sql in oracle [closed]


Your question is a little ambiguous.Is it what you want?

SELECT WELL_DPROD_DATE,
       FORMATION_NAME,
       CASE
         WHEN R1 = 1 OR R2 = 1 THEN
          FORMATION_NAME
         ELSE
          NULL
       END AS FORMATION_NAME_F
 FROM (SELECT WELL_DPROD_DATE,
           FORMATION_NAME,
           RANK() OVER(PARTITION BY FORMATION_NAME ORDER BY WELL_DPROD_DATE ASC) AS R1,
           RANK() OVER(PARTITION BY FORMATION_NAME ORDER BY WELL_DPROD_DATE DESC) AS R2
          FROM DATA_DPROD) T

1

solved Query sql in oracle [closed]