Select column in main query from sub query (derived table) -

Hi:
I have the following query - How do I select Tot_Atnd defined in the derived table
SELECT  count(distinct c.prgm_id) AS "Total Completed", h.Tot_Atnd
FROM  iplanrpt.vm_rpt_prgm  c
INNER JOIN
*(SELECT PRGM_ID, SUM(CASE WHEN ATTENDED_IND = 'Y' THEN 1 ELSE 0 END) AS "Tot_Atnd" FROM iPlanrpt.VM_RPT_PRGM_ATND GROUP BY PRGM_ID) h*
ON c.PRGM_ID = h.PRGM_ID
Thanks

Here's an example of what I think the CREATE TABLE and INSERT statements would look like for your data:
CREATE TABLE     vm_rpt_prgm
(     prgm_id     NUMBER
INSERT INTO     vm_rpt_prgm
VALUES     (1);
INSERT INTO     vm_rpt_prgm
VALUES     (2);
INSERT INTO     vm_rpt_prgm
VALUES     (3);
INSERT INTO     vm_rpt_prgm
VALUES     (1);
INSERT INTO     vm_rpt_prgm
VALUES     (1);
INSERT INTO     vm_rpt_prgm
VALUES     (3);
CREATE TABLE     vm_rpt_prgm_atnd
(     prgm_id     NUMBER
,     attended_ind     CHAR(1)
INSERT INTO     vm_prt_prgm_atnd
VALUES     (1, 'Y');
INSERT INTO     vm_prt_prgm_atnd
VALUES     (1, 'N');
INSERT INTO     vm_prt_prgm_atnd
VALUES     (2, 'Y');
INSERT INTO     vm_prt_prgm_atnd
VALUES     (2, 'Y');
INSERT INTO     vm_prt_prgm_atnd
VALUES     (2, 'N');
INSERT INTO     vm_prt_prgm_atnd
VALUES     (3, 'Y');
INSERT INTO     vm_prt_prgm_atnd
VALUES     (3, 'N');
INSERT INTO     vm_prt_prgm_atnd
VALUES     (3, 'N');But, I don't know your data. The sample data should be a simplified case of reality that represents (as best as possible) the real data set. For example, in vm_rpt_prgm, can the same prgm_id show up in multiple records? If not, the sample data I provided above is not representative of your data. Similar questions for vm_rpt_prgm_atnd: Can the same prgm_id show up in multiple records? Are the values of attended_ind 'Y' or 'N'? Can there be prgm_id's that exist in this table, but not the other? If not, again, my sample data is not representative of yours, so adjust it as needed and re-post it.
Here's some quick summary information on my sample data above:
There are 3 distinct values of prgm_id in vm_rpt_prgm.
There are 4 distinct values of prgm_id in vm_rpt_prgm_atnd.
There are 6 rows/records in vm_rpt_prgm.
There are 9 rows/records in vm_rpt_prgm_atnd.
The count of all 'Y's in vm_rpt_prgm_atnd is 5.
The count of all 'Y's in vm_rpt_prgm_atnd for only the prgm_id's in vm_rpt_prgm is 4.
So, which of these things (or other things) do you want to see in your result set?
You might say you want to see:
COUNT_OF_UNIQUE_PRGMS     TOTAL_ATND_YS
3                    4or...
PRGM_ID     TOTAL_ATND_YS
1          1
2          2
3          1
4          1Once you clearly specify what you want, I can probably help you

Similar Messages

  • How to implement 'Quick Select' column in a query result table?

    Hi,
    I have a requirement in OAF to design a search page with 'Quick select' column.
    One of the column in the query result table should be a quick select.
    Once user clicks on the quick select column, we have to navigate back to the previous page with the row value selected.
    Can anyone help me in this.
    Thanks.

    Also refer the search exercise in the toolbox tutorials.
    you can implement the quick search in the same way as update and delete buttons.
    --Prasanna                                                                                                                                                                                                                                                                                                                                   

  • How to list a calculated column in Main Report from a subreport

    Hello all,
    I am using CR 2008 and I have a coulmn in my subreport which I was to list in my main report.
    Let's say I have a main report which is run by item number and then I have a subreport where I have calculated annual usage of items and then I want to list the the annual usage in main report.
    let's I have 3 columns in my main reprot item #, description and class code and then I am calculating annual usage in a subreport and list as 4th column to my main report.
    How do I do that ?

    if you just want to pull a value from the sub report you need to create shared variables
    SHARED VARIABLES
    Shared variables are used to pass values from sub report to the main report.
    (if you want  to summarize totals from a sub report with totals from the main report, you would use the following formulas to pass the value from the sub report to main report.
    SUB REPORT               
    whileprintingrecords;
    SHARED Numbervar  X := x + ;
    MAIN                         
    whileprintingrecords;
    SHARED Numbervar  X;
    X
    Shared variables can not be suppressed.
    Make the font white and the field very small.
    They must be placed below the subreport to retrieve the value.

  • Urgent= How to Group selected columns in sql query

    Hi,
    I need some urgent help on the following sql query. I 'm sure there is an easy way to do this but I'm stacked!Any help will be much appreciated!!
    I have a query to retrieve the following columns:
    I want the first 9 columns to be grouped together (not to be repeated) for any occurence of the last 3 columns (abs.ABSENCE_START_DATE,abs.ABSENCE_END_DATE, abs.DAYS_TAKEN DAYS_TAKEN_analysis)
    SELECT DISTINCT
    sum.employee_number ,
    sum.EMPLOYEE_NAME,
    sum.EMAIL_ADDRESS,
    sum.ORGANIZATION ,
    sum.BCEBF ,
    sum.ALDE ,
    sum.CURYRREMDAYS ,
    sum.DAYS_TAKEN ,
    sum.REMBCE ,
    abs.ABSENCE_START_DATE
    abs.ABSENCE_END_DATE,
    abs.DAYS_TAKEN DAYS_TAKEN_analysis
    --TO_CHAR(TO_CHAR(abs.ABSENCE_START_DATE)||' '||TO_CHAR(abs.ABSENCE_END_DATE)||' '||TO_CHAR(abs.DAYS_TAKEN)) DAYS_TAKEN_ANAL
    FROM
    HB_V_ANNUAL_LEAVE_SUMMARY_REP SUM,
    HB_V_AN_LEAV_DAYS_TAKEN_REP ABS
    WHERE
    sum.employee_number = abs.EMPLOYEE_NUMBER
    ORDER BY
    sum.employee_number ,
    sum.EMPLOYEE_NAME,
    sum.EMAIL_ADDRESS,
    sum.ORGANIZATION ,
    sum.BCEBF ,
    sum.ALDE ,
    sum.CURYRREMDAYS ,
    sum.DAYS_TAKEN ,
    sum.REMBCE
    Any feedback/help on how to do this will be highly appreciated.
    Thanks a lot
    Elena

    Please help!!
    I used the break command to group columns that I do not want to repeat in my query output. When I run the query without formatting is working. But when I put all formatting to produce the required output I dont get the result I want.
    Below is the exact sql query I use:
    <<
    SET TERMOUT OFF
    SET ECHO OFF
    SET ARRAY 35
    SET HEA OFF
    SET FEEDBACK OFF
    SET PAGES 2000
    col beginLINE format A100
    col winsecidLINE format A100
    col placeLINE format A100
    COL LINEempty1 format A100
    COL LINEempty2 format A100
    COL LINEempty3 format A100
    COL LINEempty4 format A100
    COL LINEempty5 format A100
    COL LINEempty6 format A100
    COL LINEempty7 format A100
    COL LINEempty8 format A100
    COL LINEempty9 format A100
    COL LINEempty10 format A100
    col LINECOLempty format A100
    col receiverLINE FORMAT A100
    COL EMP_EMAIL_ADDRESS FORMAT A100
    COL LINEHEADER FORMAT A100
    COL unitsLINE FORMAT A100
    COL lmLINE FORMAT A100
    COL INTITLE FORMAT A100
    COL LINECOL1 FORMAT A100
    COL CIF FORMAT A100
    COL EMPLOYEE_NAME FORMAT A100
    COL ORGANIZATION FORMAT A100
    COL LINECOL2 FORMAT A100
    COL ALHEADER FORMAT A100
    col LINECOL3 FORMAT A100
    col BCEBF FORMAT A100
    col ALDE FORMAT A100
    COL CURYRREMDAYS FORMAT A100
    COL DAYS_TAKEN FORMAT A100
    col LINECOL4 FORMAT A100
    COL REMBCE FORMAT A100
    col LINECOL5 FORMAT A100
    col LINECOL6 FORMAT A100
    col ALHEADER2 FORMAT A100
    col LINECOL7 FORMAT A100
    col endLINE FORMAT A100
    break on beginLINE on winsecidLINE on placeLINE on LINEempty1 ON LINEempty2 ON LINEempty3 ON LINEempty4 ON LINEempty5 ON LINEempty6 ON LINEempty7 ON LINEempty8 ON LINEempty9 ON LINEempty10 on receiverLINE on EMP_EMAIL_ADDRESS on LINEHEADER on unitsLINE on lmLINE on INTITLE on LINECOL1 on CIF on EMPLOYEE_NAME on ORGANIZATION on LINECOL2 on ALHEADER on LINECOL3 on BCEBF on ALDE on CURYRREMDAYS on DAYS_TAKEN on LINECOL4 on REMBCE on LINECOL5 on LINECOL6 on ALHEADER2 on LINECOL7 ON LINEempty11 ON endREPORT on endLINE
    SPOOL C:\FORMATout.txt
    SELECT
    '{{begin}} '||chr(10) beginLINE,
    '{{winsecid 999999}} '||chr(10) winsecidLINE,
    '{{place rbsemail.tif 0 0}} '||chr(10) placeLINE,
    ' '||chr(10) LINEempty1,
    ' '||chr(10) LINEempty2,
    ' '||chr(10) LINEempty3,
    ' '||chr(10) LINEempty4,
    ' '||chr(10) LINEempty5,
    ' '||chr(10) LINEempty6,
    ' '||chr(10) LINEempty7,
    ' '||chr(10) LINEempty8,
    ' '||chr(10) LINEempty9,
    ' '||chr(10) LINEempty10,
    '{{from [email protected]}} '||chr(10) receiverLINE,
    '{{fax '|| EMAIL_ADDRESS||' }} '||chr(10) EMP_EMAIL_ADDRESS,
    '{{Subject Annual Leave Summary Report as at '||sysdate||' }} '||chr(10) LINEHEADER,
    '{{units cm}} '||chr(10) unitsLINE,
    '{{lm 2.0}} '||chr(10) lmLINE,
    'ANNUAL LEAVE SUMMARY REPORT AS AT '||sysdate INTITLE,
    '---------------------------------------------------------------------' LINECOL1,
    'CIF: '||CIF CIF,
    'EMPLOYEE NAME: '||EMPLOYEE_NAME EMPLOYEE_NAME,
    'DEPARTMENT DETAILS: '||ORGANIZATION ORGANIZATION,
    '---------------------------------------------------------------------' LINECOL2,
    'ANNUAL LEAVE DETAILS:' ALHEADER,
    '---------------------------------------------------------------------' LINECOL3,
    'BALANCE B/F FROM PREVIOUS YEAR: '||BCEBF BCEBF,
    'DAYS ENTITLED FOR THE CURRENT YEAR: '||ALDE ALDE,
    'CURRENT YEAR REMAINING DAYS: '||CURYRREMDAYS CURYRREMDAYS,
    'DAYS TAKEN FOR THE CURRENT YEAR: '||DAYS_TAKEN DAYS_TAKEN,
    '---------------------------------------------------------------------' LINECOL4,
    'REMAINING BALANCE: '||REMBCE REMBCE,
    '---------------------------------------------------------------------' LINECOL5,
    '---------------------------------------------------------------------' LINECOL6,
    'ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:' ALHEADER2,
    '---------------------------------------------------------------------' LINECOL7,
    TO_CHAR('START DATE: '||ABSENCE_START_DATE||' '||'END DATE: '||ABSENCE_END_DATE||' '||'DAYS TAKEN : '||DAYS_TAKEN_ANAL) AL_DAYS_ANAL,
    ' '||chr(10) LINEempty11,
    '-- End of Report -- '||chr(10) endREPORT,
    '{{end}} '||chr(10) endLINE
    FROM HB_V_AN_LEAV_SUM_DAYSTAKEN_REP
    WHERE CIF IN ('098033','098024')
    ORDER BY
    beginLINE ,
    winsecidLINE,
    placeLINE ,
    LINEempty1,
    LINEempty2,
    LINEempty3,
    LINEempty4,
    LINEempty5,
    LINEempty6,
    LINEempty7,
    LINEempty8,
    LINEempty9,
    LINEempty10,
    receiverLINE,
    EMP_EMAIL_ADDRESS,
    LINEHEADER ,
    unitsLINE ,
    lmLINE ,
    INTITLE ,
    LINECOL1,
    CIF ,
    EMPLOYEE_NAME ,
    ORGANIZATION ,
    LINECOL2 ,
    ALHEADER ,
    LINECOL3,
    BCEBF ,
    ALDE ,
    CURYRREMDAYS ,
    DAYS_TAKEN ,
    LINECOL4 ,
    REMBCE ,
    LINECOL5 ,
    LINECOL6 ,
    ALHEADER2 ,
    LINECOL7 ,
    LINEempty11,
    endREPORT,
    endLINE
    spool off
    >>
    The required output I want to get is:
    <<
    {{begin}}
    {{winsecid 750612}}
    {{place rbsemail.tif 0 0}}
    {{from [email protected]}}
    {{fax [email protected] }}
    {{Subject Annual Leave Summary Report as at 04-APR-08 }}
    {{units cm}}
    {{lm 2.0}}
    ANNUAL LEAVE SUMMARY REPORT AS AT 04-APR-08
    CIF: 098024
    EMPLOYEE NAME: Christou Christos Panteli
    DEPARTMENT DETAILS: 003-031-010-314-03140-Special Projects
    ANNUAL LEAVE DETAILS:
    BALANCE B/F FROM PREVIOUS YEAR: 9
    DAYS ENTITLED FOR THE CURRENT YEAR: 27
    CURRENT YEAR REMAINING DAYS: 24
    DAYS TAKEN FOR THE CURRENT YEAR: -3
    REMAINING BALANCE: 33
    ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:
    START DATE: 04-JAN-08 END DATE: 04-JAN-08 DAYS TAKEN : 1
    START DATE: 24-JAN-08 END DATE: 24-JAN-08 DAYS TAKEN : 1
    START DATE: 20-FEB-08 END DATE: 20-FEB-08 DAYS TAKEN : 1
    -- End of Report --
    {{end}}
    {{begin}}
    {{winsecid 750612}}
    {{place rbsemail.tif 0 0}}
    {{from [email protected]}}
    {{fax [email protected]}}
    {{Subject Annual Leave Summary Report as at 04-APR-08 }}
    {{units cm}}
    {{lm 2.0}}
    ANNUAL LEAVE SUMMARY REPORT AS AT 04-APR-08
    CIF: 098033
    EMPLOYEE NAME: Demetriou Elena Steliou
    DEPARTMENT DETAILS: 003-031-010-314-03140-Special Projects
    ANNUAL LEAVE DETAILS:
    BALANCE B/F FROM PREVIOUS YEAR: 15
    DAYS ENTITLED FOR THE CURRENT YEAR: 27
    CURRENT YEAR REMAINING DAYS: 25
    DAYS TAKEN FOR THE CURRENT YEAR: -2
    REMAINING BALANCE: 40
    ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:
    START DATE: 15-JAN-08 END DATE: 15-JAN-08 DAYS TAKEN : 1
    START DATE: 24-MAR-08 END DATE: 24-MAR-08 DAYS TAKEN : 1
    -- End of Report --
    {{end}}
    >>
    However the actual output we get from the above query is as follows:
    <<
    {{begin}}
    {{winsecid 750612}}
    {{place rbsemail.tif 0 0}}
    {{from [email protected]}}
    {{fax [email protected] }}
    {{Subject Annual Leave Summary Report as at 04-APR-08 }}
    {{units cm}}
    {{lm 2.0}}
    ANNUAL LEAVE SUMMARY REPORT AS AT 04-APR-08
    CIF: 098024
    EMPLOYEE NAME: Christou Christos Panteli
    DEPARTMENT DETAILS: 003-031-010-314-03140-Special Projects
    ANNUAL LEAVE DETAILS:
    BALANCE B/F FROM PREVIOUS YEAR: 9
    DAYS ENTITLED FOR THE CURRENT YEAR: 27
    CURRENT YEAR REMAINING DAYS: 24
    DAYS TAKEN FOR THE CURRENT YEAR: -3
    REMAINING BALANCE: 33
    ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:
    START DATE: 04-JAN-08 END DATE: 04-JAN-08 DAYS TAKEN : 1
    -- End of Report --
    {{end}}
    START DATE: 24-JAN-08 END DATE: 24-JAN-08 DAYS TAKEN : 1
    START DATE: 20-FEB-08 END DATE: 20-FEB-08 DAYS TAKEN : 1
    {{fax [email protected] }}
    {{Subject Annual Leave Summary Report as at 04-APR-08 }}
    {{units cm}}
    {{lm 2.0}}
    ANNUAL LEAVE SUMMARY REPORT AS AT 04-APR-08
    CIF: 098033
    EMPLOYEE NAME: Demetriou Elena Steliou
    DEPARTMENT DETAILS: 003-031-010-314-03140-Special Projects
    ANNUAL LEAVE DETAILS:
    BALANCE B/F FROM PREVIOUS YEAR: 15
    DAYS ENTITLED FOR THE CURRENT YEAR: 27
    CURRENT YEAR REMAINING DAYS: 25
    DAYS TAKEN FOR THE CURRENT YEAR: -2
    REMAINING BALANCE: 40
    ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:
    START DATE: 15-JAN-08 END DATE: 15-JAN-08 DAYS TAKEN : 1
    -- End of Report --
    {{end}}
    START DATE: 24-MAR-08 END DATE: 24-MAR-08 DAYS TAKEN : 1
    >>
    IF ANYONE CAN HELP ON THIS I WOULD REALLY APPRECIATE IT!
    THANKS A LOT!
    Best regards,
    Elena

  • Select column by comparing data from another column

    I have a table of products by their price.
    Product
    Price
    bag
    1000
    gloves
    200
    socks
    400
    hat
    100
    need to select all products where price is greater than price of "gloves"...
    Dhananjay Rele

    Select * from Table1
    where Price > (Select Max(price) from Table1
    where Product = 'gloves');
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • Automatically return to main vi from subi

    I have a main VI and a sub VI. The sub vi front panel is opened when it is called and the main VI is updated. But I need to automatically return to the main VI front panel after running the subvi
    Attachments:
    24-01-2014 main vi.vi ‏121 KB
    electron volatage sub vi.vi ‏9 KB
    mass sweep subvi.vi ‏17 KB

    Norbert_B wrote:
    Despite that, the code and interfaces should be reworked to match common development style guides (e.g. gray scale colors).
    Agreed!
    What's the point of the outer case structure of the main VI (now encompassing while loop). Are you using "continuous run" for this???
    Yes, your color scheme is just garish!
    Why do you have colored case structures on the diagram? Makes the wires hard to see (try a boolean wire in one of you case structures!). Use the default white, or, if you absolutely must, very light pastel colors as background.
    There is no reason to maximise the front panels of the subVIs, blocking everything else on the desktop. Same for the diagrams.
    You have a lot of explicit repetitive operations (e.g. string subset). That could be done in a loop instead, reducing the code to <10% of the current complexity.
    Your small cases all contain "replace substring", since this is common to all cases of each case structure, it belongs after the case structure. The case structure only needs to contain what's different (the string in this case)! Even better use a string array and index into it with the ring. No case structure needed at all!
    If you want to make the subVIs interactive, they need to wait for user input. Currently they show for a nanosecond, complete, and disappear again. (hint: while loop and event structure, for example.)
    What is the point of the flat sequence? Seems unecessary.
    There is a primitive for "equal zero". Alternatively, wire the integer to the case selector and make one case zero and the other "default".
    Your front panel has a wild mix of fonts (arial. times roman, application, etc.). Make a gobal design decision!
    Why are your LEDs distorted in random directions? Keep them all round or at least all the same shape.
    LabVIEW Champion . Do more with less code and in less time .

  • Passing YTD selection from a main query to a detailed query using RRI

    Hi,
    We have created two queries: one main query on an infocube for aggregated data, one detailed query on the feeding DSO for data at the level of sales document items.
    Both queries show monthly and YTD (year-to-date) actual cost figures.
    The user enters for instance the month of 05.2005 on the main query in a variable ZP_MONTH.
    A user exit variable ZS_YTD is calculated so that the interval 01.2005 - 05.2005 is stored in ZS_YTD.
    Revenues in the month are displayed in one column.
    Revenues in the YTD period are displayed in another column.
    Assume the data is displayed by document types.
    Then the user should select the document type and perform a jump target (Goto) to the detailed query to see which sales document items are contributing to the total revenues behind the document type.
    We have defined a ZS_YTD_2 variable on the detailed query.  It is used in the field assignments in the RSBBS transaction to receive the 0CALMONTH selection (in our case 01.2005 - 05.2005).  Then on the detailed query, we defined another userexit variable to capture the selected month based on ZS_YTD_2.
    Our issue is that when the user goes from the main query to the detailed query, the variable screen of the detailed query is being displayed with the variable ZS_YTD_2 open and the user can even change the selection there.
    Is it possible to remove the display of this intermediate variable screen?
    Thanks.

    Well.  If you unflag the variable for ready for input on the detailed query, then it is not possible for that variable to receive the period selected on the main query.  Even worse, the query crashes with the message that the variable is not correctly defined.
    Any other suggestion?
    Thanks.

  • Dynamically Specifying Selection Columns

    Hi experts,
    I'm trying to set dynamically igrid columns in java script:
    document.DetailGrid.getQueryObject().setColumns("DateTime");
    But it says there is not such method for QueryObject.
    Is there anybody who knows right method?
    Thank you..
    -Ekrem

    Looks like there is only setColumnHeaders for the GridObject. 
    The one way I know will work, but generally don't recommend it is to:
    ...getQueryObject().setQuery("Select ColumnA, ColumnB,... from TableOrViewA")
    But I think you will see a bit of a performance hit.  If you are selecting between only two or three layouts, you could change the Display Template object of the Grid Applet (or depending on your design, you could change both the query and display templates).  That would have less impact and would be easier to maintain.
    Regards,
    Mike

  • To select columns based on user's input

    hi all..
    i am beginner in oracle forms 6i..
    i want to select columns in my query according to user's input?
    how can i do it in my oracle forms 6i?
    i am using a graph in my oracle form and i want to plot graph according to user input?
    in my graph i have to show sum of only those colums which are selected by user at run time?
    how is it possible?please tell me the method in detail?

    Thanks for the Reply sir,
    When you say Write the Code, you are referring to the Package is that correct,unfortunately I am not implementing this via PL/SQL Package.
    you mentioned that I can Implement the Logic in the Data definition file( which is a XML file), how and Where I have print use that IF construct (or) Can you Please Print the Code snippet in the Model XML template that i have pasted in my Post.
    May i know what is this
    ln_req_id := fnd_request.submit_request -- for XML1 For...
    Sorry about my ignorance...

  • Unable to start from sub process

    The scenario of our application is :
    We have multiple processes,each again having multiple activities inside them.
    There is one main processes and the others are all sub processes.
    The main process looks something like below :
    Start->Sub-process1->Sub-Process2->Sub-Process3->Sub-Process4->Sub-Process5->End
    My requirement is to start the main process from Sub-Process2,rather than the usual way of instantiating the main process.
    I tried configuring Sub-Process2 as an alternative Start (in the Work Flow Builder),but that doesnt seem to be working.
    I am using Java APIs to interact with Oracle Work Flow.
    Any ideas ??
    Amit.

    One possibility is to call WF_ENGINE.CompleteActivity() if you need to start a process with an activity node that is mid-stream in a process thread and not at the beginning of a process thread. The activity node you specify as the beginning of the process must be set to 'Start' in the Node tab of its property page.
    http://download-west.oracle.com/docs/cd/B10501_01/workflow.920/a95265/wfapi42.htm#comact

  • How to freeze the selection column in the table control of the module pool.

    hi ,
    in my module pool there is a row selection field  <b>w/selcolumn</b> of the table control called as mark.
    how to freeze the selection column where there is no record in the table control row.
    or in other words where wa is initial.
    thanks
    ekta

    Hi all,
    in the PBO of the screen the following code is written.
    say the selection column is MARK and is declared in the data as well.
    thanks
    ekta
    *************************C O D E **************************************************
    MODULE disp_tabctrl1 OUTPUT.
      IF flag_c = 1.
        READ TABLE it_create_data INTO wa_material_data
             INDEX tab_ctrl1-current_line.
      ELSE.
        READ TABLE it_material_data INTO wa_material_data
             INDEX tab_ctrl1-current_line.
        IF sy-subrc = 0.
          IF ok_code_0101 = '&SEL1'.
            mark = 'X'.
          ELSEIF ok_code_0101 = '&DSEL'.
            mark = ' '.
          ENDIF.
        ELSE.
          LOOP AT SCREEN.
            IF screen-name = 'MARK'.
              screen-input = 0.
              MODIFY SCREEN.
            ENDIF.
          ENDLOOP.
        ENDIF.
      ENDIF.
      index_t = tab_ctrl1-top_line.
      index_d = tab_ctrl1-top_line + n.
    ENDMODULE.                 " DISP_TABCTRL1  OUTPUT

  • Conversion away from column type may result in sub-optimal query plan

    Hello all,
    I have the following select statement in a cursor compiled in a package.
    SELECT id
    FROM table
    WHERE TRUNC(ts) >= TRUNC(SYSDATE - p_days)
    However I get 4 warnings that read:
    PLW-07204: conversion away from column type may result in sub-optimal query plan
    Does anyone know of a way to rewrite the query to avoid the compilation warnings?
    I'm just trying to compare the date without the time...
    Thanks in advance
    Dan

    For what it is worth, whenever you compare a date column to either sysdate or any built-in function returning a date you will get that warning.
    SQL> desc t
    Name                                      Null?    Type
    ID                                                 NUMBER
    DT                                                 DATE
    SQL> SELECT DUMP(dt), DUMP(trunc(dt)), dump(sysdate)
      2  FROM t;
    DUMP(DT)                            DUMP(TRUNC(DT))                  DUMP(SYSDATE)
    Typ=12 Len=7: 120,107,7,12,15,16,43 Typ=13 Len=8: 7,215,7,12,0,0,0,0 Typ=13 Len=8: 7,215,7,12,14,16,11,0But,
    SQL> CREATE FUNCTION f(p_v IN VARCHAR2) RETURN DATE AS
      2  BEGIN
      3     RETURN TO_DATE(p_v, 'dd-mon-yyyy');
      4  END;
      5  /
    Function created.
    SQL> SELECT DUMP(f('01-jan-2000')) FROM dual;
    DUMP(F('01-JAN-2000'))
    Typ=12 Len=7: 120,100,1,1,1,1,1John

  • PLW-07204: conversion away from column type may result in sub-optimal query

    I have the following query in the package that created using sql developer. I am receiving the error 'PLW-07204: conversion away from column type may result in sub-optimal query plan' when try to compile the package. The issue is happen to be in the last line where the date is. Any help? Thanks
    select count(*) into n_cnt
    from tmp_order
    where sgn_off_dt is null and cmt_dt is not null
    and sysdate - cmt_dt > 90;

    Sy:
    Try doing as a procedure instead of an anonymous block. It looks like warnings do not apply to blocks.
    SQL> create table tmp_order(sgn_off_dt date,cmt_dt date);
    Table created.
    SQL> alter session set plsql_warnings='ENABLE:ALL';
    Session altered.
    SQL> create procedure p as
      2     n_cnt number;
      3  begin
      4     select count(*) into n_cnt
      5     from tmp_order
      6     where sgn_off_dt is null and
      7           cmt_dt is not null and
      8           sysdate - cmt_dt > 90;
      9  end;
    10  /
    SP2-0804: Procedure created with compilation warnings
    SQL> show err
    Errors for PROCEDURE P:
    LINE/COL ERROR
    8/18     PLW-07204: conversion away from column type may result in
             sub-optimal query planlindalop:
    In this case, you can ignore the warning, as it is not correct. Sysdate and a date column have different internal data types (note the type 13 for sysdate and type 12 for the date column), and whatever internally generates the warnings seems to just compare the type number.
    SQL> insert into tmp_order values(sysdate, sysdate);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select dump(sysdate) sdate, dump(cmt_dt) cmt_dt from tmp_order;
    SDATE                             CMT_DT
    Typ=13 Len=8: 7,219,2,3,15,44,4,0 Typ=12 Len=7: 120,111,2,3,16,44,12However, Oracle is perfectly capable of using an index on a date column with sysdate as a predicate. I would agree with Sy's suggestion to re-work the predicate to be something like cmt_dt < sysdate - 90.
    John

  • How can I pass/add these results in my Main query's column

    Hello Experts
    I’m working on a subquery. My subquery works fine and give the results what I need. But how can I pass/add these results in my Main query’s column ‘MGRNAME’. Here is my query
    select pc.c_id "Project ID",
    cn.c_id "Client ID", cn.c_last "Last Name", cn.c_first "First Name",
    pj.mgr_id "Manager ID", pj.project_name "Project", MGRNAME
    from project_consultant pc
    join consultant cn
    on (pc.c_id = cn.c_id)
    join project pj
    on (pc.p_id = pj.p_id)
    where lower(cn.c_last) = 'myers'
    and MGRNAME in
    ( select concat (substr(c_last,1,20),
    substr(c_first,1,20))
    as MGRNAME from consultant
    where c_id in (102, 103)
    When I run the above query I got error.
    Thanks a lot on advance

    I’ve join three tables to get the information about I need. I got everything working expert one part. The subquery
    ( select concat (substr(c_last,1,20),
    substr(c_first,1,20))
    as MGRNAME from consultant
    where c_id in (102, 103)
    Gives me the names of employees I need. The output comes 2 names. I’m trying to add these 2 names in my main query and show the results but I got the following error
    Error at Command Line:11 Column:4
    Error report:
    SQL Error: ORA-00904: "MGRNAME": invalid identifier
    00904. 00000 - "%s: invalid identifier"
    *Cause:   
    I can understand there is something wrong with MGRNAME field but not sure what it is. Can somebody point it out?
    Once again this is main query with single sub query
    select pc.c_id "Project ID",
    cn.c_id "Client ID", cn.c_last "Last Name", cn.c_first "First Name",
    pj.mgr_id "Manager ID", pj.project_name "Project",
    MGRNAME
    from project_consultant pc
    join consultant cn
    on (pc.c_id = cn.c_id)
    join project pj
    on (pc.p_id = pj.p_id)
    where lower(cn.c_last) = 'myers'
    and MGRNAME in
    ( select concat (substr(c_last,1,20),
    substr(c_first,1,20))
    as MGRNAME from consultant
    where c_id in (102, 103)
    Hope it helps

  • Selecting same column twice makes query slow

    Hello,
    Has anybody any idea why following statement is slow when selecting the
    DATA_TYPE column twice?
    SELECT S.OWNER,
    S.SYNONYM_NAME,
    UCOL.COLUMN_NAME,
    UCOL.DATA_TYPE,
    UCOL.DATA_TYPE,
    UCOL.DATA_LENGTH,
    COLUMN_ID
    FROM ALL_SYNONYMS S,
    ALL_TAB_COLUMNS UCOL
    WHERE S.TABLE_OWNER = UCOL.OWNER
    AND S.TABLE_NAME = UCOL.TABLE_NAME
    and S.owner = 'REPORTING_TEST'
    and S.SYNONYM_NAME = 'OV_COMMERCIAL_ENTITY_JN'
    Replace the owner and table name with one of your own.
    If you take one of the DATA_TYPE's out the select is much faster.
    Why, I hear you ask, do you select the same column twice?
    Well, it's not me. It's BusinessObjects when it does a structure refresh it
    produces a statement similar to the one above except that one of the
    DATA_TYPE's is a SUBSTR + DECODE (however they in themselves
    have virtually no impact on the statement). I just find it weird that repeating
    a column twice can have such a dramatic impact on performance.
    I'm not a tuning expert and have looked at EXPLAIN PLAN outputs but can't
    make head nor tail of them.
    Thanks,
    Ruud

    Yes it's true that Oracle caches data but I did run both statements several times within the same session. Run statement 1, run statement 2, add 2nd column and run again, take column away and run again, etc. Always the results were the same. The query with duplicate columns ran in seconds, the one without in milliseconds.
    If it tells you anything, below both explain plans. The main difference that I noticed is the full table scan on USER$ for the first query. The second one (although a more elaborate execution plan) seems to use indexes more.
    Don't spend too much time on this. I've found a workaround where I create temporary tables for ALL_SYNONYMS and ALL_TAB_COLUMNS and re-direct the public synonyms to point at those. After I've done what I wanted to do with BusinessObjects, I restore the original public synonyms. Next thing I'll try is rebuilding my database from scratch and see if the problem is still there.
    Apologies if the listings come out in variable font (how do you paste fixed font?).
    === SQL1 ====================================================
    EXPLAIN PLAN FOR
    SELECT UCOL.COLUMN_NAME,
    UCOL.DATA_TYPE,
    UCOL.DATA_TYPE
    FROM ALL_SYNONYMS S,
    ALL_TAB_COLUMNS UCOL
    WHERE S.TABLE_OWNER = UCOL.OWNER
    AND S.TABLE_NAME = UCOL.TABLE_NAME
    AND S.owner = 'REPORTING_TEST'
    AND S.SYNONYM_NAME = 'OV_COMMERCIAL_ENTITY_JN'
    Explained.
    Elapsed: 00:00:00.04
    SQL> @E:\Oracle\Product\10.2.0\db_1\RDBMS\ADMIN\utlxpls.sql
    Plan hash value: 1692851197
    | Id | Operation | Name |
    | 0 | SELECT STATEMENT | |
    | 1 | NESTED LOOPS | |
    | 2 | NESTED LOOPS | |
    | 3 | NESTED LOOPS | |
    | 4 | TABLE ACCESS BY INDEX ROWID | USER$ |
    |* 5 | INDEX UNIQUE SCAN | I_USER1 |
    | 6 | VIEW | ALL_TAB_COLUMNS |
    |* 7 | FILTER | |
    | 8 | NESTED LOOPS OUTER | |
    | 9 | NESTED LOOPS OUTER | |
    | 10 | NESTED LOOPS OUTER | |
    | 11 | NESTED LOOPS OUTER | |
    | 12 | NESTED LOOPS | |
    | 13 | NESTED LOOPS | |
    | 14 | TABLE ACCESS FULL | USER$ |
    | 15 | TABLE ACCESS BY INDEX ROWID| OBJ$ |
    |* 16 | INDEX RANGE SCAN | I_OBJ2 |
    |* 17 | TABLE ACCESS CLUSTER | COL$ |
    |* 18 | INDEX UNIQUE SCAN | I_OBJ# |
    |* 19 | TABLE ACCESS CLUSTER | COLTYPE$ |
    |* 20 | INDEX RANGE SCAN | I_HH_OBJ#_INTCOL# |
    |* 21 | TABLE ACCESS BY INDEX ROWID | OBJ$ |
    |* 22 | INDEX RANGE SCAN | I_OBJ3 |
    | 23 | TABLE ACCESS CLUSTER | USER$ |
    |* 24 | INDEX UNIQUE SCAN | I_USER# |
    |* 25 | TABLE ACCESS CLUSTER | TAB$ |
    |* 26 | INDEX UNIQUE SCAN | I_OBJ# |
    | 27 | NESTED LOOPS | |
    | 28 | FIXED TABLE FULL | X$KZSRO |
    |* 29 | INDEX RANGE SCAN | I_OBJAUTH2 |
    |* 30 | FIXED TABLE FULL | X$KZSPR |
    |* 31 | TABLE ACCESS BY INDEX ROWID | OBJ$ |
    |* 32 | INDEX RANGE SCAN | I_OBJ2 |
    |* 33 | TABLE ACCESS BY INDEX ROWID | SYN$ |
    |* 34 | INDEX UNIQUE SCAN | I_SYN1 |
    Predicate Information (identified by operation id):
    5 - access("U"."NAME"='REPORTING_TEST')
    7 - filter(("O"."TYPE#"=3 OR "O"."TYPE#"=4 OR "O"."TYPE#"=2 AND NOT
    EXISTS (SELECT 0 FROM "SYS"."TAB$" "T" WHERE "T"."OBJ#"=:B1 AND
    (BITAND("T"."PROPERTY",512)=512 OR BITAND("T"."PROPERTY",8192)=8192)))
    AND ("O"."OWNER#"=USERENV('SCHEMAID') OR EXISTS (SELECT 0 FROM
    "SYS"."OBJAUTH$" "OBJAUTH$",SYS."X$KZSRO" "X$KZSRO" WHERE "OBJ#"=:B2
    AND "GRANTEE#"="KZSROROL") OR EXISTS (SELECT 0 FROM SYS."X$KZSPR"
    "X$KZSPR" WHERE "INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45)
    OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
    (-"KZSPRPRV")=(-50)))))
    16 - access("O"."OWNER#"="U"."USER#")
    17 - filter(DECODE("C"."PROPERTY",0,'NO',DECODE(BITAND("C"."PROPERTY",
    32),32,'YES','NO'))='NO')
    18 - access("O"."OBJ#"="C"."OBJ#")
    19 - filter("C"."INTCOL#"="AC"."INTCOL#"(+))
    20 - access("C"."OBJ#"="H"."OBJ#"(+) AND
    "C"."INTCOL#"="H"."INTCOL#"(+))
    21 - filter("OT"."TYPE#"(+)=13)
    22 - access("AC"."TOID"="OT"."OID$"(+))
    24 - access("OT"."OWNER#"="UT"."USER#"(+))
    25 - filter(BITAND("T"."PROPERTY",512)=512 OR
    BITAND("T"."PROPERTY",8192)=8192)
    26 - access("T"."OBJ#"=:B1)
    29 - access("GRANTEE#"="KZSROROL" AND "OBJ#"=:B1)
    30 - filter("INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45) OR
    (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
    (-"KZSPRPRV")=(-50)))
    31 - filter("O"."TYPE#"=5)
    32 - access("O"."OWNER#"="U"."USER#" AND
    "O"."NAME"='OV_COMMERCIAL_ENTITY_JN')
    33 - filter("S"."NAME"="UCOL"."TABLE_NAME" AND
    "S"."OWNER"="UCOL"."OWNER")
    34 - access("O"."OBJ#"="S"."OBJ#")
    Note
    - rule based optimizer used (consider using cbo)
    === SQL2 ====================================================
    EXPLAIN PLAN FOR
    SELECT UCOL.COLUMN_NAME,
    UCOL.DATA_TYPE
    FROM ALL_SYNONYMS S,
    ALL_TAB_COLUMNS UCOL
    WHERE S.TABLE_OWNER = UCOL.OWNER
    AND S.TABLE_NAME = UCOL.TABLE_NAME
    AND S.owner = 'REPORTING_TEST'
    AND S.SYNONYM_NAME = 'OV_COMMERCIAL_ENTITY_JN'
    Explained.
    SQL>
    SQL> @E:\Oracle\Product\10.2.0\db_1\RDBMS\ADMIN\utlxpls.sql
    Plan hash value: 3285788911
    | Id | Operation | Name |
    | 0 | SELECT STATEMENT | |
    | 1 | TABLE ACCESS BY INDEX ROWID | OBJ$ |
    |* 2 | INDEX UNIQUE SCAN | I_OBJ1 |
    | 3 | TABLE ACCESS BY INDEX ROWID | OBJ$ |
    |* 4 | INDEX UNIQUE SCAN | I_OBJ1 |
    | 5 | TABLE ACCESS BY INDEX ROWID | OBJ$ |
    |* 6 | INDEX UNIQUE SCAN | I_OBJ1 |
    | 7 | TABLE ACCESS BY INDEX ROWID | OBJ$ |
    |* 8 | INDEX UNIQUE SCAN | I_OBJ1 |
    | 9 | TABLE ACCESS BY INDEX ROWID | OBJ$ |
    |* 10 | INDEX UNIQUE SCAN | I_OBJ1 |
    |* 11 | FILTER | |
    | 12 | NESTED LOOPS OUTER | |
    | 13 | NESTED LOOPS OUTER | |
    | 14 | NESTED LOOPS OUTER | |
    | 15 | NESTED LOOPS OUTER | |
    | 16 | NESTED LOOPS | |
    | 17 | NESTED LOOPS | |
    | 18 | NESTED LOOPS | |
    | 19 | NESTED LOOPS | |
    | 20 | NESTED LOOPS | |
    | 21 | TABLE ACCESS BY INDEX ROWID| USER$ |
    |* 22 | INDEX UNIQUE SCAN | I_USER1 |
    |* 23 | TABLE ACCESS BY INDEX ROWID| OBJ$ |
    |* 24 | INDEX RANGE SCAN | I_OBJ2 |
    | 25 | TABLE ACCESS BY INDEX ROWID | SYN$ |
    |* 26 | INDEX UNIQUE SCAN | I_SYN1 |
    | 27 | TABLE ACCESS BY INDEX ROWID | USER$ |
    |* 28 | INDEX UNIQUE SCAN | I_USER1 |
    | 29 | TABLE ACCESS BY INDEX ROWID | OBJ$ |
    |* 30 | INDEX RANGE SCAN | I_OBJ2 |
    |* 31 | TABLE ACCESS CLUSTER | COL$ |
    |* 32 | INDEX UNIQUE SCAN | I_OBJ# |
    |* 33 | TABLE ACCESS CLUSTER | COLTYPE$ |
    |* 34 | INDEX RANGE SCAN | I_HH_OBJ#_INTCOL# |
    |* 35 | TABLE ACCESS BY INDEX ROWID | OBJ$ |
    |* 36 | INDEX RANGE SCAN | I_OBJ3 |
    | 37 | TABLE ACCESS CLUSTER | USER$ |
    |* 38 | INDEX UNIQUE SCAN | I_USER# |
    |* 39 | TABLE ACCESS CLUSTER | TAB$ |
    |* 40 | INDEX UNIQUE SCAN | I_OBJ# |
    | 41 | NESTED LOOPS | |
    | 42 | FIXED TABLE FULL | X$KZSRO |
    |* 43 | INDEX RANGE SCAN | I_OBJAUTH2 |
    |* 44 | FIXED TABLE FULL | X$KZSPR |
    Predicate Information (identified by operation id):
    2 - access("O"."OBJ#"=:B1)
    4 - access("O"."OBJ#"=:B1)
    6 - access("O"."OBJ#"=:B1)
    8 - access("O"."OBJ#"=:B1)
    10 - access("O"."OBJ#"=:B1)
    11 - filter(("O"."TYPE#"=3 OR "O"."TYPE#"=4 OR "O"."TYPE#"=2 AND NOT
    EXISTS (SELECT 0 FROM "SYS"."TAB$" "T" WHERE "T"."OBJ#"=:B1 AND
    (BITAND("T"."PROPERTY",512)=512 OR BITAND("T"."PROPERTY",8192)=8192)))
    AND ("O"."OWNER#"=USERENV('SCHEMAID') OR EXISTS (SELECT 0 FROM
    "SYS"."OBJAUTH$" "OBJAUTH$",SYS."X$KZSRO" "X$KZSRO" WHERE "OBJ#"=:B2
    AND "GRANTEE#"="KZSROROL") OR EXISTS (SELECT 0 FROM SYS."X$KZSPR"
    "X$KZSPR" WHERE "INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45)
    OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
    (-"KZSPRPRV")=(-50)))))
    22 - access("U"."NAME"='REPORTING_TEST')
    23 - filter("O"."TYPE#"=5)
    24 - access("O"."OWNER#"="U"."USER#" AND
    "O"."NAME"='OV_COMMERCIAL_ENTITY_JN')
    26 - access("O"."OBJ#"="S"."OBJ#")
    28 - access("S"."OWNER"="U"."NAME")
    30 - access("O"."OWNER#"="U"."USER#" AND "S"."NAME"="O"."NAME")
    31 - filter(DECODE("C"."PROPERTY",0,'NO',DECODE(BITAND("C"."PROPERTY",
    32),32,'YES','NO'))='NO')
    32 - access("O"."OBJ#"="C"."OBJ#")
    33 - filter("C"."INTCOL#"="AC"."INTCOL#"(+))
    34 - access("C"."OBJ#"="H"."OBJ#"(+) AND
    "C"."INTCOL#"="H"."INTCOL#"(+))
    35 - filter("OT"."TYPE#"(+)=13)
    36 - access("AC"."TOID"="OT"."OID$"(+))
    38 - access("OT"."OWNER#"="UT"."USER#"(+))
    39 - filter(BITAND("T"."PROPERTY",512)=512 OR
    BITAND("T"."PROPERTY",8192)=8192)
    40 - access("T"."OBJ#"=:B1)
    43 - access("GRANTEE#"="KZSROROL" AND "OBJ#"=:B1)
    44 - filter("INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45) OR
    (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
    (-"KZSPRPRV")=(-50)))
    Note
    - rule based optimizer used (consider using cbo)

Maybe you are looking for

  • Font mappings on Solaris

    Hello, I am facing a problem with font mappings for Oracle Reports on Unix (Sun Solaris). I have the following "Arial Unicode MS" font installed on the Solaris Server, and wish to use it in my reports in the RTF outputs generated. /etc/openwin/fontad

  • Will The Sims 2 Play ?

    I wanna buy The Sims 2 Mac Version i looked up the specs for it here they are, will it play on my newish Macbook ? System Requirements This game runs on the Mac mini, iMac G5 or any Mac that meets the requirements below # Mac OS X 10.3.8 or later # P

  • Displaying different Queries in separate Excell Tabs

    Hello, I need to display 5 different BEx Queries on 5 seperate Tabs of an excell sheet. How is this possible?? I am working on BI 7.0. Pls help. Thanks, SD

  • WLAN for a Warehouse

    Hi, We are taking over a new warehouse in the next few months. The business has a requirement for total Wireless Coverage on the Warehouse shop floor for use by stock pickers (with mobile devices). The key challenge I see here is the fact that the ra

  • WebStart Proxy Problem

    Hey guys, i´ve got the following problem and it would be sooo great if you could help me: i´ve got 2 apps which are launched over webstart. in webstart the network connection is set to a proxy. this setting is correct for app A. the other app B shoul