Selecting and skipping rows in a table

Hi ALL, i have two tables with the following data
WITH table1 AS
  SELECT 517 id,  'TA33' cid, To_Date('1/1/2010','mm/dd/yyyy') dt,  90 src, 'MEDREC-C' name, 'FIN' lvl_1, 'FCS' lvl_2, ' BAN' lvl_3 FROM dual UNION ALL
  SELECT 517 id,  'TA33' cid, To_Date('1/1/2010','mm/dd/yyyy') dt,  88 src, 'MEDREC-L' name, 'FINA' lvl_1, 'FIC' lvl_2, ' BAN' lvl_3 FROM dual UNION all
  SELECT 517 id,  'TA33' cid, To_Date('1/1/2010','mm/dd/yyyy') dt,  91 src, 'MEDREC-H' name, 'BA' lvl_1, 'BAING' lvl_2, ' BAN' lvl_3 FROM dual UNION ALL
  SELECT 517 id,  'TA33' cid, To_Date('1/1/2010','mm/dd/yyyy') dt,  59 src, 'MEDREC-R' name, 'FIN2' lvl_1, 'FCY' lvl_2, ' BANW' lvl_3 FROM dual UNION ALL
  SELECT 517 id,  'TA33' cid, To_Date('1/5/2010','mm/dd/yyyy') dt,  90 src, 'MEDREC-C' name, 'FIN22' lvl_1, 'FCS22' lvl_2, ' BAN22' lvl_3 FROM dual UNION ALL
  SELECT 517 id,  'TA33' cid, To_Date('1/5/2010','mm/dd/yyyy') dt,  88 src, 'MEDREC-L' name, 'FINA' lvl_1, 'FIC' lvl_2, ' BAN' lvl_3 FROM dual UNION all
  SELECT 517 id,  'TA33' cid, To_Date('1/5/2010','mm/dd/yyyy') dt,  91 src, 'MEDREC-H' name, 'BA' lvl_1, 'BAING' lvl_2, ' BAN' lvl_3 FROM dual UNION ALL
  SELECT 517 id,  'TA33' cid, To_Date('1/5/2010','mm/dd/yyyy') dt,  59 src, 'MEDREC-R' name, 'FIN2' lvl_1, 'FCY' lvl_2, ' BANW' lvl_3 FROM dual UNION ALL
  SELECT 518 id,  'TA35' cid, To_Date('1/2/2010','mm/dd/yyyy') dt,  90 src, 'MEDREC-C' name, 'IND' lvl_1, 'IMAN' lvl_2, ' CO' lvl_3 FROM dual UNION all
  SELECT 518 id,  'TA35' cid, To_Date('1/2/2010','mm/dd/yyyy') dt,  88 src, 'MEDREC-L' name, 'IND' lvl_1, 'CAP' lvl_2, ' CO' lvl_3 FROM dual UNION all
  SELECT 518 id,  'TA35' cid, To_Date('1/2/2010','mm/dd/yyyy') dt,  91 src, 'MEDREC-H' name, 'EMAC' lvl_1, 'COG' lvl_2, ' CO' lvl_3 FROM dual UNION ALL
  SELECT 519 id,  'TA23' cid, To_Date('1/3/2010','mm/dd/yyyy') dt,  59 src, 'MEDREC-R' name, 'UYS' lvl_1, 'TYU' lvl_2, ' CO' lvl_3 FROM dual UNION all
  SELECT 519 id,  'TA33' cid, To_Date('1/3/2010','mm/dd/yyyy') dt,  88 src, 'MEDREC-L' name, 'UYS2' lvl_1, 'TYU2' lvl_2, ' CO2' lvl_3 FROM dual UNION ALL
  SELECT 519 id,  'TA23' cid, To_Date('1/7/2010','mm/dd/yyyy') dt,  59 src, 'MEDREC-R' name, 'UYS66' lvl_1, 'TYU66' lvl_2, ' CO1' lvl_3 FROM dual UNION all
  SELECT 519 id,  'TA33' cid, To_Date('1/7/2010','mm/dd/yyyy') dt,  88 src, 'MEDREC-L' name, 'UYS2' lvl_1, 'TYU2' lvl_2, ' CO2' lvl_3 FROM dual UNION ALL
  SELECT 520 id,  'TA2' cid, To_Date('1/4/2010','mm/dd/yyyy') dt,  88 src, 'MEDREC-L' name, 'UYS6' lvl_1, 'TYU' lvl_2, ' CO' lvl_3 FROM dual
  -- there is  more data with different id nuimbers
table2 AS
  SELECT 90 src, 'YB' name FROM dual UNION ALL
  SELECT 59 src, 'YC' name FROM dual UNION all
SELECT 91 src, 'BB' name FROM dual UNION ALL
  SELECT 88 src, 'YI' name FROM dual
)i want to write a query that gives the me output below
ID     CID        DT                  SRC     NAME         LVL_1     LVL_2       LVL_3
517     TA33     1/1/2010     90     MEDREC-C     FIN       FCS         BAN
517     TA33     1/5/2010     90     MEDREC-C     FIN22     FCS22       BAN22
518     TA35     1/2/2010     90     MEDREC-C     IND       IMAN       CO
519     TA23     1/3/2010     59     MEDREC-R     UYS       TYU         CO
519     TA23     1/7/2010     59     MEDREC-R     UYS66     TYU66       CO1this is the logic for the output above.
i am interested in rows with src value of 90 or 59
the logic should be as follow
1. if there is a row with src value of 90 and another with src value of 59 then display the row withh src=90
2. if there is a row with src value of 90 but there is no row with value 59 then display the row with src=90
3. if there is a row with src value of 59 but there is no row with value 90 then display the row with src=59
4. if there is no row with src value 59 and/or 90, then dont display anything
so for a particular id, example 517, there is a row with src=90 and 59, so i want to display the one with src=90
in id 518, there is one row with src=90 but no row with src=59. display row with src=90
in 519, there is no row with src=90, but there is one with 59, display row with src=59
id 520 dont have rows with src 90 or 59, dont display anything
i want to join table1 and table2 together. in table2 i need to get the src value so that i can join with table1.
can somebody help write a query that gives me the output above? thanks

I think this works for your 'new' logic.
WITH table1 AS
  SELECT 517 the_id,  'TA33' cid, To_Date('1/1/2010','mm/dd/yyyy') dt,  90 src, 'MEDREC-C' the_name, 'FIN' lvl_1, 'FCS' lvl_2, ' BAN' lvl_3 FROM dual UNION ALL
  SELECT 517 the_id,  'TA33' cid, To_Date('1/1/2010','mm/dd/yyyy') dt,  88 src, 'MEDREC-L' the_name, 'FINA' lvl_1, 'FIC' lvl_2, ' BAN' lvl_3 FROM dual UNION all
  SELECT 517 the_id,  'TA33' cid, To_Date('1/1/2010','mm/dd/yyyy') dt,  91 src, 'MEDREC-H' the_name, 'BA' lvl_1, 'BAING' lvl_2, ' BAN' lvl_3 FROM dual UNION ALL
  SELECT 517 the_id,  'TA33' cid, To_Date('1/1/2010','mm/dd/yyyy') dt,  59 src, 'MEDREC-R' the_name, 'FIN2' lvl_1, 'FCY' lvl_2, ' BANW' lvl_3 FROM dual UNION ALL
  SELECT 517 the_id,  'TA33' cid, To_Date('1/5/2010','mm/dd/yyyy') dt,  90 src, 'MEDREC-C' the_name, 'FIN22' lvl_1, 'FCS22' lvl_2, ' BAN22' lvl_3 FROM dual UNION ALL
  SELECT 517 the_id,  'TA33' cid, To_Date('1/5/2010','mm/dd/yyyy') dt,  88 src, 'MEDREC-L' the_name, 'FINA' lvl_1, 'FIC' lvl_2, ' BAN' lvl_3 FROM dual UNION all
  SELECT 517 the_id,  'TA33' cid, To_Date('1/5/2010','mm/dd/yyyy') dt,  91 src, 'MEDREC-H' the_name, 'BA' lvl_1, 'BAING' lvl_2, ' BAN' lvl_3 FROM dual UNION ALL
  SELECT 517 the_id,  'TA33' cid, To_Date('1/5/2010','mm/dd/yyyy') dt,  59 src, 'MEDREC-R' the_name, 'FIN2' lvl_1, 'FCY' lvl_2, ' BANW' lvl_3 FROM dual UNION ALL
  SELECT 518 the_id,  'TA35' cid, To_Date('1/2/2010','mm/dd/yyyy') dt,  90 src, 'MEDREC-C' the_name, 'IND' lvl_1, 'IMAN' lvl_2, ' CO' lvl_3 FROM dual UNION all
  SELECT 518 the_id,  'TA35' cid, To_Date('1/2/2010','mm/dd/yyyy') dt,  88 src, 'MEDREC-L' the_name, 'IND' lvl_1, 'CAP' lvl_2, ' CO' lvl_3 FROM dual UNION all
  SELECT 518 the_id,  'TA35' cid, To_Date('1/2/2010','mm/dd/yyyy') dt,  91 src, 'MEDREC-H' the_name, 'EMAC' lvl_1, 'COG' lvl_2, ' CO' lvl_3 FROM dual UNION ALL
  SELECT 519 the_id,  'TA23' cid, To_Date('1/3/2010','mm/dd/yyyy') dt,  59 src, 'MEDREC-R' the_name, 'UYS' lvl_1, 'TYU' lvl_2, ' CO' lvl_3 FROM dual UNION all
  SELECT 519 the_id,  'TA33' cid, To_Date('1/3/2010','mm/dd/yyyy') dt,  88 src, 'MEDREC-L' the_name, 'UYS2' lvl_1, 'TYU2' lvl_2, ' CO2' lvl_3 FROM dual UNION ALL
  SELECT 519 the_id,  'TA23' cid, To_Date('1/7/2010','mm/dd/yyyy') dt,  59 src, 'MEDREC-R' the_name, 'UYS66' lvl_1, 'TYU66' lvl_2, ' CO1' lvl_3 FROM dual UNION all
  SELECT 519 the_id,  'TA33' cid, To_Date('1/7/2010','mm/dd/yyyy') dt,  88 src, 'MEDREC-L' the_name, 'UYS2' lvl_1, 'TYU2' lvl_2, ' CO2' lvl_3 FROM dual UNION ALL
  SELECT 520 the_id,  'TA2'  cid, To_Date('1/4/2010','mm/dd/yyyy') dt,  88 src, 'MEDREC-L' the_name, 'UYS6' lvl_1, 'TYU' lvl_2, ' CO' lvl_3 FROM dual
   table2 AS
  SELECT 90 src, 'YB' the_name FROM dual UNION ALL
  SELECT 59 src, 'YC' the_name FROM dual UNION all
  SELECT 91 src, 'BB' the_name FROM dual UNION ALL
  SELECT 88 src, 'YI' the_name FROM dual
SELECT
   results.the_id              ,
   results.cid                 ,
   results.dt                  ,
   results.src                 ,
   results.the_name            ,
   results.lvl_1               ,
   results.lvl_2               ,
   results.lvl_3               ,
   t2.the_name AS tab2_the_name
FROM
      SELECT
         the_id  ,
         cid     ,
         dt      ,
         src     ,
         the_name,
         lvl_1   ,
         lvl_2   ,
         lvl_3   ,
         CASE
            WHEN src IN (59, 90)
            THEN rank() over (partition BY the_id order by
               CASE
                  WHEN src IN (59,90)
                  THEN src
                  ELSE -100
               END DESC )
            ELSE NULL
         END AS rn
      FROM
         table1
   results,
   table2 t2
WHERE
   results.src = t2.src
AND
      rn  = 1
   OR rn IS NULL
            THE_ID CID  DT                                  SRC THE_NAME LVL_1 LVL_2 LVL_3  TA
               517 TA33 01-JAN-2010 12 00:00                 90 MEDREC-C FIN   FCS    BAN   YB
               517 TA33 05-JAN-2010 12 00:00                 90 MEDREC-C FIN22 FCS22  BAN22 YB
               517 TA33 05-JAN-2010 12 00:00                 91 MEDREC-H BA    BAING  BAN   BB
               517 TA33 05-JAN-2010 12 00:00                 88 MEDREC-L FINA  FIC    BAN   YI
               517 TA33 01-JAN-2010 12 00:00                 91 MEDREC-H BA    BAING  BAN   BB
               517 TA33 01-JAN-2010 12 00:00                 88 MEDREC-L FINA  FIC    BAN   YI
               518 TA35 02-JAN-2010 12 00:00                 90 MEDREC-C IND   IMAN   CO    YB
               518 TA35 02-JAN-2010 12 00:00                 88 MEDREC-L IND   CAP    CO    YI
               518 TA35 02-JAN-2010 12 00:00                 91 MEDREC-H EMAC  COG    CO    BB
               519 TA23 03-JAN-2010 12 00:00                 59 MEDREC-R UYS   TYU    CO    YC
               519 TA23 07-JAN-2010 12 00:00                 59 MEDREC-R UYS66 TYU66  CO1   YC
               519 TA33 03-JAN-2010 12 00:00                 88 MEDREC-L UYS2  TYU2   CO2   YI
               519 TA33 07-JAN-2010 12 00:00                 88 MEDREC-L UYS2  TYU2   CO2   YI
               520 TA2  04-JAN-2010 12 00:00                 88 MEDREC-L UYS6  TYU    CO    YI
14 rows selected.
Elapsed: 00:00:00.25
ME_XE?

Similar Messages

  • Difference between current row and previous row in a table

    Hi All,
    I am having a problem with the query. Can some of please help me?
    I need to get difference between current row and previous row in a table. I have a table, which have data like bellow.
    TABLEX
    ================
    Name Date Items
    AAA 01-SEP-09 100
    BBB 02-SEP-09 101
    CCC 03-SEP-09 200
    DDD 04-SEP-09 200
    EEE 05-SEP-09 400
    Now I need to get output like bellow...
    Name Date Items Diff-Items
    AAA 01-SEP-09 100 0
    BBB 02-SEP-09 101 1
    CCC 03-SEP-09 200 99
    DDD 04-SEP-09 200 0
    EEE 05-SEP-09 400 200
    Can some one help me to write a query to get above results?
    Please let me know if you need more information.
    Thanks a lot in advance.
    We are using Oracle10G(10.2.0.1.0).
    Thanks
    Asif

         , nvl (items - lag (items) over (order by dt), 0)like in
    SQL> with test as
      2  (
      3  select 'AAA' name, to_date('01-SEP-09', 'dd-MON-rr') dt,  100 items from dual union all
      4  select 'BBB' name, to_date('02-SEP-09', 'dd-MON-rr') dt,  101 items from dual union all
      5  select 'CCC' name, to_date('03-SEP-09', 'dd-MON-rr') dt,  200 items from dual union all
      6  select 'DDD' name, to_date('04-SEP-09', 'dd-MON-rr') dt,  200 items from dual union all
      7  select 'EEE' name, to_date('05-SEP-09', 'dd-MON-rr') dt,  400 items from dual
      8  )
      9  select name
    10       , dt
    11       , items
    12       , nvl (items - lag (items) over (order by dt), 0)
    13    from test
    14  ;
    NAM DT             ITEMS NVL(ITEMS-LAG(ITEMS)OVER(ORDERBYDT),0)
    AAA 01-SEP-09        100                                      0
    BBB 02-SEP-09        101                                      1
    CCC 03-SEP-09        200                                     99
    DDD 04-SEP-09        200                                      0
    EEE 05-SEP-09        400                                    200
    SQL>

  • Selection of a row in  a table

    Hi,
    I have a problem with JTable. ...i have just started working with JTables and still have not got a complete hang of how they function.
    I have a table whose model is "AbstractTableModel". I have different data in each row of the table therefore i have a celledtior and cell renderer per row. Each row is rendered as a combo box. There is only one column in that table. What i need to do is when the user clicks on any of these the rows in the table i need to evaluate what is the content in that row(in the combo box-It should be the values that have not been used up yet in the other rows...so basically as you add rows the combo box content will keep shrinking till all the possible vlaues are exhausted).
    I added a celleditor listener for every row. When the user clicks on the cell the event get's captured but the row value that shows up is not row the user selected. The value is always the previous selected row. Each cell is rendered as a combo box.
    For example if the user selected the first row in the table then the value of the row selected is -1. If the the user adds two more rows and selects the third row then the value selected is 0 (previos selected).
    What i cannot figure out is how in the world is this value obtained.
    Please help !! I tried everything i can think of to get the correct value of the row selected.
    Thanks a lot for your time and patience.
    Archana

    Hello Suman,
    Please, look at 'No First Select from Table' section of this blog: [/people/jarrod.williams/blog/2006/12/14/visual-composer-tips-and-tricks|/people/jarrod.williams/blog/2006/12/14/visual-composer-tips-and-tricks]
    Good luck,
    Ola

  • Insert row and delete row in a table control

    Hi Experts,
    I am using a table control in module pool programming, How can I Insert row and delete row in a table control?
    Thanks in Advance....

    Santhosh,
    Iam using this code..
    FORM fcode_delete_row
                  USING    p_tc_name           TYPE dynfnam
                           p_table_name
                           p_mark_name   .
    -BEGIN OF LOCAL DATA----
      DATA l_table_name       LIKE feld-name.
    data: p_mark_name type c.
      FIELD-SYMBOLS <tc>         TYPE cxtab_control.
      FIELD-SYMBOLS <table>      TYPE STANDARD TABLE.
      FIELD-SYMBOLS <wa>.
      FIELD-SYMBOLS <mark_field>.
    -END OF LOCAL DATA----
      ASSIGN (p_tc_name) TO <tc>.
    get the table, which belongs to the tc                               *
      CONCATENATE p_table_name '[]' INTO l_table_name. "table body
      ASSIGN (l_table_name) TO <table>.                "not headerline
    delete marked lines                                                  *
      DESCRIBE TABLE <table> LINES <tc>-lines.
      LOOP AT <table> ASSIGNING <wa>.
      access to the component 'FLAG' of the table header                 *
        ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.
    if <MARK_FIELD> = 'X'.
        PERFORM f_save_confirmation_9101.
        IF gv_answer EQ '1'.
          DELETE <table> INDEX syst-tabix.
          IF sy-subrc = 0.
            <tc>-lines = <tc>-lines - 1.
          ENDIF.
          ELSE.
          ENDIF.
        ENDIF.
      ENDLOOP.
    in this code   ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.
    if <MARK_FIELD> = 'X'.
    this code is not working...

  • Drag and drop row within same table.

    Version 12.1.2
    I am trying to implement drag and drop row within same table, and I am trying to follow this sample from Frank:
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/106-reorder-table-rows-1921121.pdf
    But, I am getting this cast exception. The code I have in my dropEvent bean is identical to whats on the sample.
    oracle.jbo.server.ViewRowImpl cannot be cast to oracle.jbo.uicli.binding.JUCtrlHierNodeBinding
    ADF_FACES-60097:For more information, please see the server's error log for an entry beginning with: ADF_FACES-60096:Server Exception during PPR, #1
    Not sure if anything has changed on 12c release, or if I am missing anything.
    Here is my complete code:
    public DnDAction doDnD(DropEvent dropEvent) {
    RichTable table = (RichTable) dropEvent.getDragComponent();
    List dropRowKey = (List) dropEvent.getDropSite();
    if (dropRowKey == null) {
    return DnDAction.NONE;
    Transferable t = dropEvent.getTransferable();
    DataFlavor<RowKeySet> df = DataFlavor.getDataFlavor(RowKeySet.class, "rowmove");
    RowKeySet rks = t.getData(df);
    Iterator iter = rks.iterator();
    List draggedRowKey = (List) iter.next();
    JUCtrlHierNodeBinding draggeRowNode = (JUCtrlHierNodeBinding) table.getRowData(draggedRowKey);
    Row dragRow = draggeRowNode.getRow();
    JUCtrlHierNodeBinding dropRowObject = (JUCtrlHierNodeBinding) table.getRowData(dropRowKey);
    Row dropRow = dropRowObject.getRow();
    //get the table's ADF JUCtrlHierBinding
    CollectionModel collectionModel = (CollectionModel) table.getValue();
    JUCtrlHierBinding treeBinding = (JUCtrlHierBinding) collectionModel.getWrappedData();
    DCIteratorBinding objectsIterator = treeBinding.getDCIteratorBinding();
    RowSetIterator rsi = objectsIterator.getRowSetIterator();
    int indexOfDropRow = rsi.getRangeIndexOf(dropRow);
    dragRow.removeAndRetain();
    rsi.insertRowAtRangeIndex(indexOfDropRow, dragRow);
    objectsIterator.setCurrentRowIndexInRange(indexOfDropRow);
    AdfFacesContext adfctx = AdfFacesContext.getCurrentInstance();
    adfctx.addPartialTarget(table.getParent());
    return DnDAction.MOVE;
    It does not seem to like this line of code:
    JUCtrlHierNodeBinding draggeRowNode = (JUCtrlHierNodeBinding) table.getRowData(draggedRowKey);
    I would greatly appreciate any help.
    Thanks.

    Well there has bee a changes somehow. using 12c
    table.getRowData(draggedRowKey);
    returns a ViewRowImpl and no longer anything which can be convertet to JUCtrlHierNodeBinding. Anyway, the fix is easy:
        public DnDAction onDepartmentsRowDrop(DropEvent dropEvent) {
            //get the table instance. This information is later used
            //to determine the tree binding and the iterator binding
            RichTable table = (RichTable) dropEvent.getDragComponent();
            List dropRowKey = (List) dropEvent.getDropSite();
            //if no dropsite then drop area was not a data area
            if (dropRowKey == null) {
                return DnDAction.NONE;
            //The transferable is the payload that contains the dragged row's
            //row key that we use to access the dragged row handle in the ADF
            //iterator binding
            Transferable t = dropEvent.getTransferable();
            //get the row key set of the dragged row. The "rowmove" string is the
            //discriminant defined on the drag source and the collectionDrop target.
            DataFlavor<RowKeySet> df = DataFlavor.getDataFlavor(RowKeySet.class, "rowmove");
            RowKeySet rks = t.getData(df);
            Iterator iter = rks.iterator();
            //for this use case the re-order of rows is one-by-one, which means that the rowKeySet
            //should only contain a single entry. If it contains more then still we only look at a
            //singe (first) row key entry
            List draggedRowKey = (List) iter.next();
            //get access to the oracle.jbo.Row instance represneting this table row
            Object objdragg = table.getRowData(draggedRowKey);
            Row dragRow = (Row) objdragg;
            Object objdrop = table.getRowData(dropRowKey);
            Row dropRow = (Row) objdrop;
            //get the table's ADF JUCtrlHierBinding
            CollectionModel collectionModel = (CollectionModel) table.getValue();
            JUCtrlHierBinding treeBinding = (JUCtrlHierBinding) collectionModel.getWrappedData();
            //get access to the ADF iterator binding used by the table and the underlying RowSetIterator.
            //The RowSetIterator allows us to remove and re-instert the dragged row
            DCIteratorBinding departmentsIterator = treeBinding.getDCIteratorBinding();
            RowSetIterator rsi = departmentsIterator.getRowSetIterator();
            int indexOfDropRow = rsi.getRangeIndexOf(dropRow);
            //remove dragged row from collection so it can be added back
            dragRow.removeAndRetain();
            rsi.insertRowAtRangeIndex(indexOfDropRow, dragRow);
            //make row current in ADF iterator.
            departmentsIterator.setCurrentRowIndexInRange(indexOfDropRow);
            //ppr the table
            AdfFacesContext adfctx = AdfFacesContext.getCurrentInstance();
            //note that the refresh of the table didn't work when refreshing the table
            //so I needed to refresh the container component (af:panelStretchLayout).
            adfctx.addPartialTarget(table.getParent());
            return DnDAction.MOVE;
    does the trick. I changed the line to
    //get access to the oracle.jbo.Row instance represneting this table row
            Object objdragg = table.getRowData(draggedRowKey);
            Row dragRow = (Row) objdragg;
    so you don't need the detour through the JUCtrlHierNodeBinding any longer.
    Timo

  • Default selection of a row in the table

    Dear all,
    I have given output of one table as the  input to an RFC and the output of this RFC is given to a table and the same scenario we followed for the graphs also. By default first row of the table is getting selected because of that the second table or graph is getting displayed without any user interaction. Please tell us how can we avoid the above. I tried by using guard condition of select but i am unable to control it. Please tell us detailed procedure by which directly i can follow the same.
    Regards,
    Suman.

    Hello Suman,
    Please, look at 'No First Select from Table' section of this blog: [/people/jarrod.williams/blog/2006/12/14/visual-composer-tips-and-tricks|/people/jarrod.williams/blog/2006/12/14/visual-composer-tips-and-tricks]
    Good luck,
    Ola

  • How to select x numbered row from two tables

    Hi,
    I have one performance problem...
    Here is sample scenario...
    TableA
    A1 A2 A3
    a1     a12     a13
    a2     a22     a23
    a3     a32     a33
    TableB
    B1     B2     B3
    b1     b12     b13
    b2     b22     b23
    I want result like
    A1     B1     A2     B2
    a1     b1     a12     b12
    a2     b2     a22     b22
    I have written it like
    select
    A1,
    B1,
    A2,
    B2
    from
    (select A1, A2, rownum rnA from TableA) a,
    (select B1, B2, rownum rnB from TableB) b
    where rnA = rnB
    but suppose TableA has 2500000 rows and
    TableB has 500 rows then for 500 rows I have to
    wait for all 2500000 rows scanning.
    Is there any smart solution..?
    I have created indexes for on columns A1, (A1,A2,A3), B1, (B1,B2,B3).
    Curious:)
    Rushang Kansara
    Message was edited by:
    Rushang Kansara

    Here is explain plan
    SELECT STATEMENT, GOAL = FIRST_ROWS               Cost=5     Cardinality=67     Bytes=3618
    HASH JOIN               Cost=5     Cardinality=67     Bytes=3618
    VIEW     Object owner=SFMFG          Cost=2     Cardinality=82     Bytes=2214
    COUNT                         
    TABLE ACCESS FULL     Object owner=SFMFG     Object name=TABLEA     Cost=2     Cardinality=82     Bytes=1148
    VIEW     Object owner=SFMFG          Cost=2     Cardinality=82     Bytes=2214
    COUNT                         
    TABLE ACCESS FULL     Object owner=SFMFG     Object name=TABLEB     Cost=2     Cardinality=82     Bytes=1148
    New to sql tunning Here why cardinality goes to 67 and cost to 5???
    Thank you for your time.. :)

  • Reg Selection of  Multiple Rows in a Table

    Hi all,
    I have to select multiple rows from a table and have to display those selected records in another table in the next screen.
    The problem is, when I am selecting the records in a table, selection should not be allowed on some records based on a condition. Is it possible with the default selection mode of webdynpro. If so, Please tell me how can we disable the selection of certain records in a table(using the default selection mode provided by webdynpro)
    Else, if we have to use check boxes for selection(in case of my problem), please do help me out in how to disable the selection of certain records in a table(using check boxes for selection).
    Please help me out. Its urgent...
    Reward points guranteed.
    Regards,
    Murthy.

    HI Narayana,
    Multiple selection  property is specific to a table, not for a tableElment(ie. for a row), so u cant set some of the rows as multi selected and some as node
    U can use Checkbox for this purpose. Based on the condition u can make the check box as enabled and disabled
    To achieve this, Create 2 boolean variables inside table node, one for checkbox value(Let it be <b>CBValue</b> .Bind this to checked property of Checkbox) and other for enabling and disabling Checkbox(Let it be <b>CBReadOnly</b>. Bind this to readonly property of CheckBox).
    At the time of creation of table elements, as per the condition, u can control the selection as
    IPrivate<View>.I<Table>Node tNode=wdContext.node<Table>();
    for(int i=0;i<5;i++)
    IPrivate<View>.I<Table>Element tEl=tNode.create<Table>Element();
    tNode.addElement(tEl);
    tEl.setCBValue(false);//Unchecking Checkboxes initially
    if(condition=non selectable)
      tEl.setCBReadOnly(true);
    else
      tEl.setCBReadOnly(false)
    Regards
    Fahad Hamsa

  • Adding 2 more rows to a select without inserting rows to base table

    hello all,
    i have a below simple select statement which is querying a table.
    select * from STUDY_SCHED_INTERVAL_TEMP
    where STUDY_KEY = 1063;
    but here is the situations. As you can see its returning 7 rows. But i need to add
    2 more rows..with everything else default value or what exist... except adding 2 more rows.
    i cannot insert into base table. I want my end results to increment by 2 days in
    measurement_date_Taken to 01-apr-09....so basically measurement_date_taken should
    end at study_end_Date...
    IS THAT EVEN POSSIBLE WITHOUT INSERTING ROWS INTO THE TABLE AND JUST PLAYIHY AROUND WITH
    THE SELECT STATEMENT??
    sorry if this is confusing...i am on 10.2.0.3
    Edited by: S2K on Aug 13, 2009 2:19 PM

    Well, I'm not sure if this query looks as good as my lawn, but seems to work anyway ;)
    I've used the 'simplified version', but the principle should work for your table to, S2K.
    As Frank already pointed out (and I stumbled upon it while clunging): you just select your already existing rows and union them with the 'missing records', you calculate the number of days you're 'missing' based on the study_end_date:
    MHO%xe> alter session set nls_date_language='AMERICAN';
    Sessie is gewijzigd.
    Verstreken: 00:00:00.01
    MHO%xe> with t as ( -- generating your data here, simplified by me due to cat and lawn
      2  select 1063 study_key
      3  ,      to_date('01-MAR-09', 'dd-mon-rr') phase_start_date
      4  ,      to_date('02-MAR-09', 'dd-mon-rr') measurement_date_taken
      5  ,      to_date('01-APR-09', 'dd-mon-rr') study_end_date
      6  from dual union all
      7  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('04-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
      8  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('09-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
      9  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('14-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
    10  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('19-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
    11  select 1063, to_date('22-MAR-09', 'dd-mon-rr') , to_date('23-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
    12  select 1063, to_date('22-MAR-09', 'dd-mon-rr') , to_date('30-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual
    13  ) -- actual query:
    14  select study_key
    15  ,      phase_start_date
    16  ,      measurement_date_taken
    17  ,      study_end_date
    18  from   t
    19  union all
    20  select study_key
    21  ,      phase_start_date
    22  ,      measurement_date_taken + level -- or rownum
    23  ,      study_end_date
    24  from ( select study_key
    25         ,      phase_start_date
    26         ,      measurement_date_taken
    27         ,      study_end_date
    28         ,      add_up
    29         from (
    30                select study_key
    31                ,      phase_start_date
    32                ,      measurement_date_taken
    33                ,      study_end_date
    34                ,      study_end_date - max(measurement_date_taken) over (partition by study_key
    35                                                                          order by measurement_date_taken ) add_up
    36                ,      lead(measurement_date_taken) over (partition by study_key
    37                                                          order by measurement_date_taken ) last_rec
    38                from   t
    39              )
    40         where last_rec is null
    41       )
    42  where rownum <= add_up
    43  connect by level <= add_up;
    STUDY_KEY PHASE_START_DATE    MEASUREMENT_DATE_TA STUDY_END_DATE
          1063 01-03-2009 00:00:00 02-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 04-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 09-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 14-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 19-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 23-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 30-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 31-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 01-04-2009 00:00:00 01-04-2009 00:00:00
    9 rijen zijn geselecteerd.If there's a simpler way (in SQL), I hope others will join and share their example/ideas/thoughts.
    I have a feeling that this is using more resources than needed.
    But I've got to cut the daisies first now, they interfere my 'lawn-green-ess' ;)

  • Adding and Removing Rows from a Table

    So first time user here so hold on. I am creating a form in Adobe, using the LiveCycle Designer. It has help files on creating a table and having it grow as data is entered. So I create a table and follow the steps but nothing happens. Not sure what I am doing wrong here.
    CustomerTable.Row1.instanceManager.addInstance(1);
    This is code for my button. It is place in the first data row of the table. I inserted a subform so that I could have to buttons there.
    I labeled everything accordingly (my table is called 'CustomerTable'). When I go to previeiw or save it and open as a regular pdf i will not give me more rows to enter information in. Is this syntax wrong or am I just retarded today?
    Ben

    Post your question in the LiveCycle Designer forum.

  • Query about min and max and middle row of a table

    suppose i have table emp and field
    v_date date;
    which has data in time stamp
    time
    10:20
    10:25
    10:30
    10:32
    10:33
    10:35
    10:36
    10:38
    I need only min time and max time and two record between min and max

    I need only min time and max time and two record between min and max Like this?
    SQL> create table t (id number);
    Table created.
    SQL>
    SQL> insert into t values (1020);
    1 row created.
    SQL> insert into t values (1025);
    1 row created.
    SQL> insert into t values (1030);
    1 row created.
    SQL> insert into t values (1032);
    1 row created.
    SQL> insert into t values (1033);
    1 row created.
    SQL> insert into t values (1035);
    1 row created.
    SQL> insert into t values (1036);
    1 row created.
    SQL> insert into t values (1038);
    1 row created.
    SQL>
    SQL> commit;
    Commit complete.
    SQL>
    SQL> select * from t;
         ID
       1020
       1025
       1030
       1032
       1033
       1035
       1036
       1038
    8 rows selected.
    SQL>
    SQL>
    SQL> select decode(rownum, 1, min_val, 4, max_val, next_val) your_data from (
      2  select first_value (id) over (partition by 'a' order by 'a') min_val,
      3         last_value (id) over (partition by 'a' order by 'a')  max_val,
      4         id,
      5         lead(id) over (partition by 'a' order by id) next_val
      6   from t
      7  order by id
      8   )
      9  where min_val <> next_val and max_val <> next_val
    10  and rownum <= 4;
    YOUR_DATA
         1020
         1030
         1032
         1038
    SQL>

  • Cannot select column or rows in a table

    I've created two column document - but for some reason cannot select the columns so that I can format them. The selection menu items are grayed out. And when hovering with curser the curser does not convert to arrow to enable 'select'. I just want to add lines around the table columns but can't. Anyone know solution? Must be something simple I did when setting up the two column document . . . .

    Rich,
    Select one cell, then Right-Click or Control-Click, for the contextual menu:
    or Choose Menu > Format > Table > Select Row / Column.
    Regards,
    Jerry

  • How can I select and delete rows based on the value in one column?

    I searched through the discussion board, and found a thread on deleting blank rows, but not sure how to modify it to work with my issue.
    I have put together a rather complicated spreadsheet for designing control systems, it calculates parts needed based on check boxes selected in a second spreadsheet.
    Since not all systems require all parts there are many rows that have a 0 quantity value, I would like to select these rows and delete them once I have gone through the design phase (checking off required features on a separate sheet).
    I like the way the other thread I found will gather all the blank rows at the bottom without changing the order of the rows with data in them.
    I don't understand exactly how the formula in the other thread works well enough to modify it to look for a certain column.
    I hope I made myself clear enough here, to recap, I would like to sort the rows based on a zero value in one (quantity) column, move them (the zero quantity rows) to the bottom of the sheet, and then delete the rows with a zero quantity (I can delete them manually, but would like to automate the sorting part).
    Thanks for any help anyone can provide here.
    Danny

    I apologize but, as far as I know, Numbers wasn't designed by Ian Flemming.
    There is no "this column will be auto-destructing after two minutes"
    You will have to use your fingers to delete it.
    I wish to add a last comment :
    if your boss has the bad habit to look over your shoulder, it's time to find an other one.
    As I am really pig headed, it's what I did. I became my own boss so nobody looked over my shoulder.
    Yvan KOENIG (VALLAURIS, France) mercredi 13 juillet 2011 20:30:25
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8
    Please : Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • "Top n" selection and percentages in a pivot table

    Hi all,
    I have a problem with calculating/display of percentage figures in a pivot table that I need some help on.
    For a given month, I'm reporting the web browser logins, by browser type. So for example:
    2010/03, IE, 50
    2010/03, Firefox, 30
    2010/03, Chrome, 10
    2010/03, Others, 10
    Totalling 100 ( and their produce the same value as a % ). However, if I apply a filter on the browser that does a select of the Top 2 for the month, the IE & Firefox total 80 and displays the % values as:
    2010/03, IE, 62.5%
    2010/03, Firefox, 37.5%.
    So I can see that really what I need to do is to filter the columns being displayed as the "Top 2" not selecting the data onbeing in the top 2.
    Can anyone advise on how to do this/is it possible.
    Thanks in advance.

    Hi you can try like,
    1. create a duplicate column for browserlogins and set its level as month and name it as totallogin.
    2. create a calculated measure for the original browserlogins column. Choose the totallogin to compare against that column.
    3. choose percent in the new calculation tab.
    4. Bring this column iinto the presentation layer.
    5. use this column in the report.
    Check what it is showing. I dint try this out. Just a guess. If its helpful award some points.
    Thanks,
    Karthick

  • How to diasble selection for particular rows in a Table?

    im currently working on a multiple select table.. i need to disable the checkbox for some particular rows. How can i get runtime control over that cell??

    To disable one or more rows of single or multiple selection in your table, add the following code to your controller processRequest method:
    OATableBean tableBean = ...;
    tableBean.setSelectionDisabledBindingAttr("Disabled");
    In the example above, "Disabled" represents the Boolean view attribute that returns 1/"Y" if one or more rows is (are) to be disabled, otherwise it returns 0/"N". The view attribute "Disabled" must belong to the same view object as the one associated with the table items.
    If its an advanced table, use the same method on OAAdvancedTableBean instead.

Maybe you are looking for

  • Converting a text string to a date in Discoverer

    I've got a problem with a discoverer report which is that an item is pointing to a field in the Oracle table which is named as a segment4. This appears to be a generic field which stores any type of data, as it is based on the result of a flex-field

  • So how do I REALLY get the toolbar buttons to just show icons (and not text)?

    On my Bookmarks toolbar, my bookmarks "buttons" show icon AND text. I just want to show icon, not text. When I go right-click.....customize, the window "customize toolbars" opens. Down in the bottom left corner the "show" option dropdown is already s

  • Converting binary digits to its decimal equivalent.

    Is there any methods to do such convertion ?? Have been doing the hard way. :(

  • Can I do a Stop Motion Movie in iMovie?

    Can I make a stop motion video from a bunch of stills in iMovie? I can't figure out where to start... not to mention iMovie seems to think I'm in love with the Ken Burns effect, which I'm not and has applied it to every one of my frames. I can't remo

  • BI 4.0 WebI desginer shaky with BEx query as source

    Hi All, I am working WebI on BI 4.0 with both WebI Rich client and launching WebI through BI launch pad. In both cases when drilling down query output after refresh, the output blurred or shaky. Previously I was on old Java version now I have updated