Home » SQL & PL/SQL » SQL & PL/SQL » how to use analytic functions in this case (oracle 10g)
how to use analytic functions in this case [message #447886] Thu, 18 March 2010 05:56 Go to next message
chaituu
Messages: 115
Registered: June 2008
Senior Member

DATA is like this;i want to insert to same set of rows again with increasing the MAIN_SEQ with 4,5,6.

DOCUMENT_ID MAIN_SEQ
VSISLG401 1
VSISLG401 2
VSISLG401 3

DATA is like this;i want to insert to same set of rows again with increasing the MAIN_SEQ with 4,5,6.

DOCUMENT_ID      MAIN_SEQ
VSISLG401      1
VSISLG401      2
VSISLG401      3



INSERT INTO TEMP_TEST 
SELECT JC.DOCUMENT_ID, 
       (SELECT MAX(JC1.MAIN_SEQ) + 1 
          FROM CHARGE JC1 
         WHERE JC1.DOCUMENT_ID = JC.DOCUMENT_ID) 
  FROM CHARGE JC 
 WHERE JC.ID = '126';

Re: how to use analytic functions in this case [message #447889 is a reply to message #447886] Thu, 18 March 2010 06:11 Go to previous message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Why do you think you need an analytic function? Analytic function is not a silver bullet for all queries you don't know how to write.

Just use "max(...)+rownum"

Regards
Michel
Previous Topic: Case in sql statement doesn't run in PLSql block
Next Topic: pdf from pl/sql
Goto Forum:
  


Current Time: Sun Dec 11 06:29:49 CST 2016

Total time taken to generate the page: 0.04137 seconds