Aggregation of analytic functions not allowed

Hi all, I have a calculated field called Calculation1 with the following calculation:
AVG(Resolution_time) KEEP(DENSE_RANK FIRST ORDER BY RANK ) OVER(PARTITION BY "User's Groups COMPL".Group Name,"Tickets Report #7 COMPL".Resource Name )
The result of this calculation is correct, but is repeated for all the rows I have in the dataset.
Group Name      Resourse name    Calculation1
SH Group            Mr. A            10
SH Group            Mr. A            10
SH Group            Mr. A            10
SH Group            Mr. A            10
SH Group            Mr. A            10
5112 rowsI tried to create another calculation in order to have only ONE value for the couple "Group Name, Resource Name) as AVG(Calculation1) but I have the error: Aggregation of analytic functions not allowed
I saw also inside the "Edit worksheet" panel that the Calculation1 *is not represented* with the "Sigma" symbol I(as for example a simple AVG(field_1)) and inside the SQL code I don't have GROUP BY Group Name, Resource Name......
I'd like to see ONLY one row as:
Group Name      Resourse name    Calculation1
SH Group            Mr. A            10....that it means I grouped by Group Name, Resource Name
Anyone knows how can I achieve this result or any workarounds ??
Thanks in advance
Alex

Hi Rod unfortunately I can't use the AVG(Resolution_time) because my dataset is quite strange...I explain to you better.
Ι start from this situation:
!http://www.freeimagehosting.net/uploads/6c7bba26bd.jpg!
There are 3 calculated fields:
RANK is the first calculated field:
ROW_NUMBER() OVER(PARTITION BY "User's Groups COMPL".Group Name,"Tickets Report Assigned To & Created By COMPL".Resource Name,"Tickets Report Assigned To & Created By COMPL".Incident Id  ORDER BY  "Tickets Report Assigned To & Created By COMPL".Select Flag )
RT Calc is the 2nd calculation:
CASE WHEN RANK = 1 THEN Resolution_time END
and Calculation2 is the 3rd calculation:
AVG(Resolution_time) KEEP(DENSE_RANK FIRST ORDER BY  RANK ) OVER(PARTITION BY "User's Groups COMPL".Group Name,"Tickets Report Assigned To & Created By COMPL".Resource Name )
As you can see, from the initial dataset, I have duplicated incident id and a simple AVG(Resolution Time) counts also all the duplication.
I used the rank (based on the field "flag) to take, for each ticket, ONLY a "resolution time" value (in my case I need the resolution time when the rank =1)
So, with the Calculation2 I calculated for each couple Group Name, Resource Name the right AVG(Resolution time), but how yuo can see....this result is duplicated for each incident_id....
What I need instead is to see *once* for each couple 'Group Name, Resource Name' the AVG(Resolution time).
In other words I need to calculate the AVG(Resolution time) considering only the values written inside the RT Calc fields (where they are NOT NULL, and so, the total of the tickets it's not 14, but 9).
I tried to aggregate again using AVG(Calculation2)...but I had the error "Aggregation of analytic functions not allowed"...
Do you know a way to fix this problem ?
Thanks
Alex

Similar Messages

  • Getting an error - group function not allowed here

    Below is the merge statement...
    getting an error - group function not allowed here
    WHY????
    merge into summary
    using
    (select
    a.user_id,
    min(a.start_time_utc),
    max(a.end_time_utc),
    sum(a.duration_seconds),
    /*total_upload
    total_download
    total_traffic,*/
    max(r.package_id),
    last_usage_charge, -------hard coded
    max(r.peak_rate),
    max(r.bst_plantype),
    max(r.free_value), ---for free value
    a.IsPeak,
    sum(a.TotalDiscount)
    from aaa_sessions a,rate_plan r,subscriber_info si
    where
    si.EXTERNAL_ID=a.USER_ID
    and
    si.PACKAGE_ID=r.PACKAGE_ID
    group by
    user_id,bst_plantype,ispeak)t ------do we need to use alias here
    on
    (summary.user_id=t.user_id
    and
    summary.type_of_summary=t.bst_plantype
    and
    summary.ispeak=t.ispeak)
    When matched then
    update
    set
    start_date =decode((t.start_time_utc-summary.start_date)-abs(t.start_time_utc-summary.start_date),0,summary.start_date,t.start_time_utc),
    end_date=decode((t.end_time_utc-summary.end_date)-abs(t.end_time_utc-summary.end_date),0,t.end_time_utc,s.end_date),
    total_duration=summary.total_duration+sum(duration_seconds),
    total_upload=summary.total_upload+sum(upload_bytes),
    total_download=summary.total_download+sum(download_bytes),
    total_traffic=summary.total_upload+sum(upload_bytes)+summary.total_download+sum(download_bytes)
    When not matched then
    INSERT
    (user_id ,
    start_date,
    end_date,
    total_duration,
    /*total_upload
    total_download
    total_traffic,*/
    rate_plan_id,
    last_usage_charge,
    peak_rate,
    type_of_summary,
    IsPeak,
    TotalDiscount)
    VALUES
    (t.user_id,
    t.start_time_utc,
    t.end_time_utc,
    t.duration_seconds,
    /*t.output_bytes,
    t.input_bytes,
    t.output_bytes+aa.input_bytes,*/
    t.PACKAGE_ID,
    1, ---hard coded the value
    t.PEAK_RATE,
    t.BST_PLANTYPE,
    t.ispeak,
    t.free_value);

    This is the query,...
    Its giving no complilation errors..
    I have not used aggregate functions in the insert/update..
    have used only decode...
    and nowhere i found that aggegate functions not allowed in the insert/update stmts of merge..
    Can u please post a link where it is mentioned...
    MERGE INTO summary
    USING (SELECT a.user_id, MIN (a.start_time_utc) stc,
    MAX (a.end_time_utc) etc, SUM (a.duration_seconds) ds,
    SUM (a.download_bytes) download,
    SUM (a.upload_bytes) upload, MAX (r.package_id) pkg_id,
    MAX (r.peak_rate) p_rate, MAX (r.offpeak_rate)
    ofp_rate,
    MAX (r.bst_plantype) plan_type,
    SUM (r.free_value) free_val, a.ispeak,
    MAX (r.peak_pulse) p_pulse,
    MAX (r.offpeak_pulse) ofp_pulse
    FROM aaa_sessions a, rate_plan r, subscriber_info si
    WHERE si.external_id = a.user_id
    AND si.package_id = r.package_id
    GROUP BY user_id, bst_plantype, ispeak) t
    ON ( summary.user_id = t.user_id
    AND summary.type_of_summary = t.plan_type
    AND summary.rate_plan_id = t.pkg_id
    AND summary.ispeak = t.ispeak)
    WHEN MATCHED THEN
    UPDATE
    SET start_date =
    DECODE ( (t.stc - summary.start_date)
    - ABS (t.stc - summary.start_date),
    0, summary.start_date,
    t.stc
    end_date =
    DECODE ( (t.etc - summary.end_date)
    - ABS (t.etc - summary.end_date),
    0, t.etc,
    summary.end_date
    total_duration = summary.total_duration + t.ds,
    total_download = summary.total_download + t.download,
    total_upload = summary.total_upload + t.upload,
    total_traffic =
    summary.total_upload
    + t.upload
    + summary.total_download
    + t.download,
    last_usage_charge =
    DECODE (t.plan_type,
    0, (t.ds - t.free_val)
    / DECODE (t.ispeak, 0, t.ofp_pulse, p_pulse)
    * DECODE (t.ispeak, 0, t.ofp_rate, t.p_rate),
    ((t.download + t.upload) - t.free_val
    * DECODE (t.ispeak, 0, t.ofp_rate, t.p_rate)
    WHEN NOT MATCHED THEN
    INSERT (user_id, start_date, end_date, total_duration,
    total_download, total_upload, total_traffic, rate_plan_id,
    last_usage_charge, peak_rate, type_of_summary, ispeak,
    totaldiscount)
    VALUES (t.user_id, t.stc, t.etc, t.ds, t.download, t.upload,
    t.download + t.upload, t.pkg_id,
    DECODE (t.plan_type,
    0, (t.ds - t.free_val)
    / DECODE (t.ispeak, 0, t.ofp_pulse, p_pulse)
    * DECODE (t.ispeak, 0, t.ofp_rate, t.p_rate),
    ((t.download + t.upload) - t.free_val
    * DECODE (t.ispeak, 0, t.ofp_rate, t.p_rate)
    t.p_rate, t.plan_type, t.ispeak, t.free_val);
    COMMIT;

  • Iphoto share functions not allowed

    Since a reload of OSX by Apple store to fix a problem on imac, the share function of iphoto is greyed out.
    Permissions are set to read/write "you have custom access"
    Why is this happening?
    How do I fix this?

    Cured by "restarting" the imac.

  • Analytic Functions in PL/SQL

    This procedure won't compile - the word PARTITION seems to be the problem - with this error...
    PLS-00103: Encountered the symbol "(" when expecting one of the following: , from
    The query in the cursor runs correctly as a stand-alone query. Can analytic functions not be used in PL/SQL cursors?
    Thanks.
    CREATE OR REPLACE
    PROCEDURE TestAnalyticFunction IS
    CURSOR GetAllTransTypes_Cursor IS
    select transaction_class.trans_desc,
    transaction_code.trans_type ,
    transaction_code.trans_code,
    transaction_code.trans_code_desc,
    sum(tr_tx_amt) as trans_sum,
    RATIO_TO_REPORT(sum(tr_tx_amt)) OVER
    (PARTITION BY transaction_code.trans_type) AS Percentage
    from transaction_code,
    transaction_class,
    transactions
    where TR_POST_DT IS NOT NULL
    AND TR_POST_DT >= '01-DEC-2000'
    AND TR_POST_DT <= '31-JAN-2001'
    AND TRANSACTION_CODE.TRANS_CLASS = TRANSACTION_CLASS.TRANS_CLASS_ID
    AND TRANSACTION_CODE.TRANS_CODE = TRANSACTIONS.TR_TX_CODE
    AND TRANSACTION_CODE.TRANS_TYPE in (1,2,3,4,5,8)
    group by transaction_code.trans_type,
    trans_class,
    trans_desc,
    trans_code,
    trans_code_desc
    order by transaction_code.trans_type, trans_code;
    TYPE TransClassDescType IS TABLE OF transaction_class.trans_desc%TYPE;
    TYPE TransCodeTypeType IS TABLE OF transaction_code.trans_type%TYPE;
    TYPE TransCodeCodeType IS TABLE OF transaction_code.trans_code%TYPE;
    TYPE TransCodeDescType IS TABLE OF transaction_code.trans_code_desc%TYPE;
    TYPE TotalType IS TABLE OF NUMBER(14,2);
    TYPE TotalPctType IS TABLE OF NUMBER(6, 2);
    TransClassDesc TransClassDescType;
    TransCodeType TransCodeTypeType;
    TransCodeCode TransCodeCodeType;
    TransCodeDesc TransCodeDescType;
    Total TotalType;
    TotalPct TotalPctType;
    BEGIN
    OPEN GetAllTransTypes_Cursor;
    FETCH GetAllTransTypes_Cursor BULK COLLECT INTO TransClassDesc,TransCodeType,TransCodeCode,TransCodeDesc,
    Total, TotalPct;
    CLOSE GetAllTransTypes_Cursor;
    END TestAnalyticFunction;
    null

    Some functions just don't seem to work in PL/SQL even though they work fine in SQL*Plus.
    Two such functions I found were NVL2 and RATIO_TO_REPORT.
    Have no clue why yet.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Dale Johnson ([email protected]):
    This procedure won't compile - the word PARTITION seems to be the problem - with this error...
    PLS-00103: Encountered the symbol "(" when expecting one of the following: , from
    The query in the cursor runs correctly as a stand-alone query. Can analytic functions not be used in PL/SQL cursors?
    Thanks.
    CREATE OR REPLACE
    PROCEDURE TestAnalyticFunction IS
    CURSOR GetAllTransTypes_Cursor IS
    select transaction_class.trans_desc,
    transaction_code.trans_type ,
    transaction_code.trans_code,
    transaction_code.trans_code_desc,
    sum(tr_tx_amt) as trans_sum,
    RATIO_TO_REPORT(sum(tr_tx_amt)) OVER
    (PARTITION BY transaction_code.trans_type) AS Percentage
    from transaction_code,
    transaction_class,
    transactions
    where TR_POST_DT IS NOT NULL
    AND TR_POST_DT >= '01-DEC-2000'
    AND TR_POST_DT <= '31-JAN-2001'
    AND TRANSACTION_CODE.TRANS_CLASS = TRANSACTION_CLASS.TRANS_CLASS_ID
    AND TRANSACTION_CODE.TRANS_CODE = TRANSACTIONS.TR_TX_CODE
    AND TRANSACTION_CODE.TRANS_TYPE in (1,2,3,4,5,8)
    group by transaction_code.trans_type,
    trans_class,
    trans_desc,
    trans_code,
    trans_code_desc
    order by transaction_code.trans_type, trans_code;
    TYPE TransClassDescType IS TABLE OF transaction_class.trans_desc%TYPE;
    TYPE TransCodeTypeType IS TABLE OF transaction_code.trans_type%TYPE;
    TYPE TransCodeCodeType IS TABLE OF transaction_code.trans_code%TYPE;
    TYPE TransCodeDescType IS TABLE OF transaction_code.trans_code_desc%TYPE;
    TYPE TotalType IS TABLE OF NUMBER(14,2);
    TYPE TotalPctType IS TABLE OF NUMBER(6, 2);
    TransClassDesc TransClassDescType;
    TransCodeType TransCodeTypeType;
    TransCodeCode TransCodeCodeType;
    TransCodeDesc TransCodeDescType;
    Total TotalType;
    TotalPct TotalPctType;
    BEGIN
    OPEN GetAllTransTypes_Cursor;
    FETCH GetAllTransTypes_Cursor BULK COLLECT INTO TransClassDesc,TransCodeType,TransCodeCode,TransCodeDesc,
    Total, TotalPct;
    CLOSE GetAllTransTypes_Cursor;
    END TestAnalyticFunction;<HR></BLOCKQUOTE>
    null

  • System SAP does not allow to post a journal that is not balancing?

    According to the implementation of controllers SOX in the company, I need
    to verify if the SAP ERP system must like standard functionality not
    allow to record documents that are not balanced (debit = credit).
    I appreciate its collaboration and I am awaiting its commentaries

    Hi
    SAP Follows the document principle which means that unless the debit is equal to credit in a document you cant save the document.
    This is based on the double entry system of book keeping and in sync with the accounting principles accepted world over.
    I hope im clear
    Assign points if useful
    Regards
    Aravind

  • Not allow em console

    Hi!
    I downloaded and installed production version SOA 10.1.3 .1 , but after installation
    I can't use em console . It is function not allowed for me
    What's happened ? Why I can't use it ? ((((
    PS : I installed advanced installation
    Message was edited by:
    user539017

    Is there any way to activate it AFTER the installation? I forgot to enable during the installation but i'd really appreciate it now.
    Thanks for your help
    Martin

  • Surprised that 1Z0-047 (SQL Expert) does not include Analytic Functions

    Apparently, from a reading of the 1Z0-047 outline,  Analytic Functions are not "in scope" for the Exam.
    Comments, anyone ?
    Hemant K Chitale

    Comments, anyone ?
    There are definitely some gaps in the SQL coverage on that exam. I could see the exam being redone (and improved) for 12C much as 1Z0-144 was rewritten for 11G as a much improved version of 1Z0-147.  I'd like to see them remove the individual listing of topics pulled from SQL Fundamentals.  They should be replaced with either a much-compressed list or a single note that knowledge of SQL fundamentals is assumed.  This might help with the level of confusion newbies have over which test they should take.
    Adding all of the functions you mention would not only make the test more comprehensive but also allow the tone of the exam to be altered.  Right now I consider it to be filled with questions intended to misdirect the test candidate.  The questions are 'tricky' rather than 'difficult'. This is largely because SQL is inherently easy to read so the only way to make it hard *is* to write deliberately bad SQL. Adding more advanced topics would allow for more questions that don't have to be made artificially more difficult.

  • Function return value == -10. Native error code -2146824584 ADOBD.Recordset: Operation is not allowed when object is closed

    I want to call Stored Procedure that return records and output parameter, from CVI
    I can get output parrameter but when I want to get records stream I recieve following wrror:
    function return value == -10. Native error code -2146824584 ADOBD.Recordset: Operation is not allowed when object is closed

    in Stored procedure I create table variable and and insert into string values
    when I remove usage of table variable the error desappear

  • Error while creating Notification: Partner Function is Not Allowed in Partner Determination Profile Q2

    During Notification Creation I get the error --Partner Function is Not Allowed in Partner Determination Profile Q2
    As I enter Purchase Document Number in the transaction QM01 and press Enter. I get the above error and donot go further.
    Can anyone help me here.

    Hello Prashant,
    You are missing some configuration for the partner function;
    Go- to
    SPRO>IMG>QM>Quality Notifications>Notification Creation>Partners>Define partner Determination Procedure>
    Again Select "Define Partner Determination Procedure".
    Select Quality management> Change Partner
    Now Select Q2.
    Compare settings with Partner Determination Procedure on any other client. Also check Partner functions on the same screen.
    Amol.

  • PL/SQL equivalent of T-SQL - "group function is not allowed here"

    Hi all, hope someone can give me a hand as I'm pretty stuck! I have been trying to convert some MS SQL Server T-SQL statements into Oracle PL/SQL and am stuck on the below one:
    SELECT
    CA.AssessmentID,
    (SELECT ProductName + ISNULL(' - ' + PrincipalBenefit,'')
    FROM rptPolicySnapshot WHERE PolicyID = MAX(CA.PolicyID)
    AND SnapshotID = 1),
    MAX(CA.PolicyID)
    FROM rptClaimInvoiceLineSnapshot CIL
    INNER JOIN rptClaimAssessmentSnapshot CA
    ON CIL.AssessmentID = CA.AssessmentID
    AND CIL.SnapshotID = CA.SnapshotID
    WHERE CIL.SnapshotID = 1
    GROUP BY CA.AssessmentID
    This works fine in MSSQL but returns the below error in Oracle:
    'ORA-00934: group function is not allowed here'
    If I take out the subquery the query works fine.
    Any ideas as to the syntax? I am new to Oracle so not sure as to how I should go about writing this.
    Thanks in advance!
    Leo

    WITH x AS (SELECT   ca.assessmentid,
                        MAX (ca.policyid) policy_id
               FROM rptclaiminvoicelinesnapshot cil
                    INNER JOIN rptclaimassessmentsnapshot ca
                        ON cil.assessmentid = ca.assessmentid
                       AND cil.snapshotid = ca.snapshotid
               WHERE cil.snapshotid = 1
               GROUP BY ca.assessmentid
    SELECT x.assessment_id,
           x.policy_id,
           productname + decode(principalbenefit,null,null,' - ' || principalbenefit ) prodname
    FROM   rptpolicysnapshot, x
    WHERE  policyid = x.policy_id
    AND    snapshotid = 1I think that's in the neighbourhood.

  • I am trying to edit my website using the copy and paste function and am getting an error message that says my browser will not allow this function.. what do I do? thanks!

    I am trying to do a simple copy and paste function while editing my website and I am getting an error message that says that my browser will not allow this function.. how can I override this?
    thanks
    Doug Snyder

    You need to set Copy'n'Paste security policies for that domain in Firefox.
    AllowClipboard Helper will help you do that. <br />
    https://addons.mozilla.org/en-US/firefox/addon/allowclipboard-helper/

  • RFC Function Module - Message Reference parameters are not allowed with RFC

    Hi,
    I’ve checked the Remote-Enabled Module radio button, declared Import and Export parameters using ‘Type’ typing and checked the ‘Pass Value’ in export and import parameters but I still receive message ‘Reference parameters are not allowed with RFC’ and not able to activate the function module.
    Am I missing something?
    Regards,
    ...Naddy

    Hi all,
                   I faced the same problem and solved it ,
    You have defined a reference parameter for a remotely called
      function module. However, only value parameters are allowed
      for this type of module.
      Procedure
      Change the reference parameter to a value parameter.
    Guys  pls .don't leave the thread un-asnwered when you solved problem , post the solution it might be useful for others also.
    Regards
    Krishna Acharya

  • Subquery not allowed - PL/SQL Function Body returning bolean

    Is subquery is not allowed in PL/SQL Expresion.????
    I am using the following query in one of my derived report column but I am getting the error.
    BEGIN
    if :COL1<>'abc' and :COL2 in (select deptno from dept1) then
    return 1;
    elsif :COL1<>'abc' and :COL2 in (select deptno from dept2) then
    return 0;
    elsif :COL1<>'abc' and :COL2 in (select deptno from dept3) then
    return 1;
    else
    return 0;
    end if;
    END;
    secondly CAN I use return value such as 'ABC' or 'XYZ' other than 0,1.
    Error-
    Invalid function body condition: ORA-06550: line 4, column 8: PLS-00405: subquery not allowed in this context ORA-06550: line 2, column 3: PL/SQL: Statement ignored
    -----------------

    Hi Deepak,
    There are at least methods.
    1 - You could create a SQL function that returned 0 or 1 and use that in your statement
    2 - You could use a CASE clause in the SQL statement
    As I don't have your dept1/2/3 tables, I've tried the following on the sample EMP/DEPT tables:
    SELECT EMPNO,
    ENAME,
    SAL,
    COMM,
    DEPTNO,
    CASE WHEN DEPTNO IN (SELECT DEPTNO FROM DEPT) THEN
      CASE WHEN ENAME LIKE '%A%' THEN NVL(SAL,0) + NVL(COMM,0) ELSE 456 END
    ELSE
       CASE WHEN DEPTNO NOT IN (SELECT DEPTNO FROM DEPT) THEN
         CASE WHEN ENAME LIKE '%A%' THEN NVL(SAL,0) + NVL(COMM,0) ELSE 123 END
       ELSE
         789
       END
    END "TOTAL"
    FROM EMPThis returns the values I expect:
    EMPNO     ENAME     SAL     COMM     DEPTNO     TOTAL
    7936     ATD     3000     -      40     3000
    7958     dino4     -      -      -      789
    7839     KINGS     5000     -      40     456
    7698     BLAKES     2850     -      30     2850
    7782     CLARK     2450     -      10     2450
    7566     JONES     2975     -      30     456
    7788     SCOTT     3000     -      20     456
    7902     FORD     3000     -      40     456
    7369     SMITH     800     -      20     456
    7499     ALLEN     1600     300     30     1900Obviously, you may have to experiment with the various CASE statements, but it will work using just a sql select statement.
    Andy

  • Discoverer Analytic Function windowing - errors and bad aggregation

    I posted this first on Database General forum, but then I found this was the place to put it:
    Hi, I'm using this kind of windowing function:
    SUM(Receitas Especificas) OVER(PARTITION BY Tipo Periodo,Calculado,"Empresa Descrição (Operador)","Empresa Descrição" ORDER BY Ini Periodo RANGE BETWEEN INTERVAL '12' MONTH PRECEDING AND INTERVAL '12' MONTH PRECEDING )
    If I use the "Receitas Especificas SUM" instead of
    "Receitas Especificas" I get the following error running the report:
    "an error occurred while attempting to run..."
    This is not in accordance to:
    http://www.boku.ac.at/oradoc/ias/10g(9.0.4)/bi.904/b10268.pdf
    but ok, the version without SUM inside works.
    Another problem is the fact that for analytic function with PARTITION BY,
    this does not work (shows the cannot aggregate symbol) if we collapse or use "<All>" in page items.
    But it works if we remove the item from the PARTITION BY and also remove from workbook.
    It's even worse for windowing functions(query above), because the query
    only works if we remove the item from the PARTITION BY but we have to show it on the workbook - and this MAKES NO SENSE... :(
    Please help.

    Unfortunately Discoverer doesn't show (correct) values for analytical functions when selecting "<All>" in a page item. I found out that it does work when you add the analytical function to the db-view instead of to the report as a calculation or as a calculated item on the folder.
    The only problem is you've to name all page-items in the PARTITION window, so, when adding a page-item to the report, you,ve to change the db-view and alter the PARTITION window.
    Michael

  • Forms 10g not supporting Analytical functions

    Hi all
    i try to use analytic funtion like
         row_number() over (partition by uuid order by timesheet_acct) rn
    but form did not compile this while when i run the same analytic function in SQL prompt it runs fine. is forms support Analytical functions?? if not then what can i do for performing this task at form??
    thx.

    Ok, so look at this stored function:
    CREATE OR REPLACE FUNCTION Return_Cursor
      PC$Select IN VARCHAR2
    ) RETURN SYS_REFCURSOR
    IS
      cc  SYS_REFCURSOR ;
    BEGIN
      OPEN cc FOR PC$Select ;
      RETURN cc ;
    END ;
    /Then imagine you can call it with ANY query like the following:
    SQL> set serveroutput on
    SQL> DECLARE
      2     cur SYS_REFCURSOR ;
      3     CURSOR c IS SELECT deptno, ename, sal FROM EMP ;
      4     rec c%ROWTYPE ;
      5     LC$Req  VARCHAR2(2000) ;  
      6    BEGIN
      7      LC$Req := 'SELECT deptno, ename, sal FROM ' ;
      8      LC$Req := LC$Req || '(SELECT deptno, ename, sal, row_number() over ' ;
      9      LC$Req := LC$Req || '(PARTITION BY deptno ORDER BY sal DESC) FROM EMP ORDER BY deptno, sal)' ;
    10      cur := Return_Cursor( LC$Req ) ;
    11      LOOP
    12        FETCH cur INTO rec ;
    13        EXIT WHEN cur%NOTFOUND ;
    14        dbms_output.put_line( rec.DEPTNO || '  ' || rec.ENAME || ' -> ' || rec.SAL ) ;
    15      END LOOP ;
    16      CLOSE cur ;
    17  END;
    18  /
    10  MILLER -> 1301
    10  CLARK -> 2450
    10  KING -> 5000
    20  SMITH -> 915
    20  ADAMS -> 1100
    20  JONES -> 2975
    20  SCOTT -> 3000
    20  FORD -> 3000
    30  JAMES -> 950
    30  WARD -> 1250
    30  MARTIN -> 1250
    30  TURNER -> 1500
    30  ALLEN -> 1600
    30  BLAKE -> 2850
    Procédure PL/SQL terminée avec succès.What do you think ?
    Francois

Maybe you are looking for

  • Re-create dmsys user

    DMSYS schema was accidently dropped on standard 11.2.0.2. Recreated. However, when I queried the dba_registry, Oracle data mining is still invalid. ORA-39126: Worker unexpected fatal error in SYS.KUPW$WORKER.GET_TABLE_DATA_OBJECTS [] ORA-31642: the f

  • Problems Launching Dw

    I recently purchased CS5.  Although other applications (e.g. Photoshop, Illustrator) seem to work just fine, when I try to lauch Dw I get an error message: "No document types have been found in the Configuration/DocumentTypes/ folder.  The MMDocument

  • See example (don't know the right words ;)

    i'm starting a new spreadsheet tomorrow and it's going to require me to do this (sorry, i don't even know the right words to use to describe it.. much less the formula names) basically: A1 = 5 A2 = 6 return = 6, 12, 18, 24, 30 or 6*1, 6*2, 6*3 etc un

  • IPhone has 7.0 os and says there are no updates

    My iPhone 4S IOS is 7.0.  I am told by others that there is a 7.02 yet my phone says there are no updates.  What's my problem?

  • Can not delete ICloud email drafts after sending

    I can not delete email drafts that showup after sending an email via icloud.  Any suggestions?