Oracle
 sql >> डेटाबेस >  >> RDS >> Oracle

लापता संख्या स्क्रिप्ट काम नहीं करेगी?

यह उदाहरण देखें

WITH ORDH
     AS (SELECT 1111 AS ORDERNO FROM DUAL
         UNION ALL
         SELECT 1112 AS ORDERNO FROM DUAL
         UNION ALL
         SELECT 1115 AS ORDERNO FROM DUAL
         UNION ALL
         SELECT 1116 AS ORDERNO FROM DUAL
         UNION ALL
         SELECT 1118 AS ORDERNO FROM DUAL
         UNION ALL
         SELECT 1121 AS ORDERNO FROM DUAL),
     GOT_NEXT_ORDERNO
     AS (SELECT ORDERNO,
                LEAD ( ORDERNO ) OVER (ORDER BY ORDERNO) AS NEXT_ORDERNO
         FROM   ORDH)
SELECT ORDERNO + 1 AS FROM_NO, NEXT_ORDERNO - 1 AS TO_NO
FROM   GOT_NEXT_ORDERNO
WHERE  ORDERNO + 1 <> NEXT_ORDERNO;

   FROM_NO      TO_NO
---------- ----------
      1113       1114
      1117       1117
      1119       1120

3 rows selected.



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. ओरेकल ट्रिगर डालने या हटाने के बाद

  2. ojdbc14.jar बनाम ojdbc6.jar

  3. Oracle में CLOB को BLOB में कैसे बदलें?

  4. Oracle 10g में एक टेबल कॉलम का नाम कैसे बदलें

  5. APPLSYSPUB स्कीमा