Select line if found, otherwise select between rows

Oracle 11.2.0.1

Windows

create table test (col1 number);

Insert test values (10957);

Insert test values (10958);

Insert test values (10959);

Insert test values (10960);

Insert test values (10972);

Insert test values (10973);

Insert test values (10980);

Insert test values (10982);

SQL > select * from test where myfunct (10960) = true;

COL1

----------

10960

If I said value 10962 then output should be these lines that comes between the values.

SQL > select * from test where myfunct (10962) = true;

COL1

----------

10960 <-10960 min is closest to 10962

10972 <-10972 max is the closer of 10692

even similar;

SQL > select * from test where myfunct (10981) = true;

COL1

----------

10980

10982

If I select which is out of reach of min/max all the then only I should get any selected lines.

SQL > select * from test where myfunct (10983) = true;

or

SQL > select * from test where myfunct (10956) = true;

no selected line

I have no idea how to choose this line if col1 = given, otherwise the lines min/max who comes between the two given the value and no line if the given value is min/max in the col1 values.

Kindly help me.

Thank you.

Always use the SQL because SQL purse always faster than anything. But if you want to get the result by running the function you can create pipelined function.

SQL > CREATE or REPLACE TYPE obj_testCol1 AS OBJECT (collar number);

2.

Creative type

SQL > CREATE or REPLACE TYPE obj_testCol1_table IS TABLE OF THE obj_testCol1;

2.

Creative type

SQL >

SQL > CREATE or REPLACE function MyPF (n number)

2 return obj_testCol1_table

3 PIPELINED is type t_ref_cursor IS REF CURSOR;

4

t_ref_cursor rf_c 5;

6 r_out_rec obj_testCol1: = obj_testCol1 (null);

7. start

8

9. open rf_c for

10

11. Select col1

12 years of test

13 where col1 = n

14 union of all the

15 select col1

16 from (select *)

17 in (select row_number() over (partition by sign (col1 - n) order to decode (sign (col1 - n),-1, abs (col1 - n), col1 - n)) r,)

18 max (col1) over() mx.

19 min (col1) over() minutes.,

20                             col1

21 test

22 where does not exist (select 1 test where col1 = n))

where the 23 mx > = to_number (n)

24 and mn<=>

25 where r = 1;

26

27 LOOP

28 rf_c FETCH

29 IN r_out_rec.col;

30

EXIT 31 WHEN rf_c % NOTFOUND;

PIPE 32 ROW (r_out_rec);

33 END LOOP;

34

35 CLOSE rf_c;

36 end;

37.

Feature created

SQL > select * from table (MyPF (10960));

COL

----------

10960

SQL > select * from table (MyPF (10962));

COL

----------

10960

10972

SQL > select * from table (MyPF (10983));

COL

----------

SQL >

----

Ramin Hashimzade

Tags: Database

Similar Questions

  • Popup event on the selection of rows in table tree

    I use jdev 11.1.1.7

    I followed below page to pass parameters between the regions. It works fine if I use a button to trigger the event & pass the id of selected in a table of the tree line.

    Tech Blog of Rohan Walia: events background - Basic step by step: ADF

    I wanted to avoid button, I'm trying to pass data directly on the selection of rows in the tree.

    < eventBinding id = "eventBinding".

    Listener = "org. Apache.MyFaces.Trinidad.Event.SelectionListener">

    " < events xmlns =" http://xmlns.Oracle.com/ADFM/contextualEvent "> "

    < name of event = 'FireEvent '.

    customPayLoad="#{pageFlowScope.ManageOrgsBean.selectedID}"/ >

    < / events >

    < / eventBinding >

    < / links >

    " < events xmlns =" http://xmlns.Oracle.com/ADFM/contextualEvent "> "

    < name of event = 'FireEvent '.

    customPayLoad="#{pageFlowScope.ManageOrgsBean.selectedID}"/ >

    < / events >

    I get a NPE in the 3rd line below:

    {} public void onTreeNodeSelect (SelectionEvent selectionEvent)

    BindingContainer DCBindingContainer = ADFUtils.getDCBindingContainer ();

    JUEventBinding eventBinding = (JUEventBinding) bindingContainer.get ("FireEvent");

    SelectionListener selectionListener (SelectionListener) = eventBinding.getListener (); NPE

    selectionListener.processSelection (selectionEvent);

    }

    Any idea? Thank you.

    Try with:

    JUEventBinding eventBinding = (JUEventBinding) bindingContainer.get ('eventBinding');

  • 12.1.3 JDeveloper and table for selection of rows in Internet Explorer 9

    Configuration: Windows 7, Internet Explorer 9 12.1.3, JDeveloper (sorry, the company standard for now)

    I have problems of selection of rows in a table when you use IE9 (disabled compatibility view) as my browser.  I created a simple application to test.  I did the following:

    1 created a new web application from merger in JDev 12.1.3.

    2 objects of business created for 1 table

    3. create a simple page (jspx) for testing

    4 dropped the table on the side of Center of a PanelStretchLayout on the page as a table read-only with sorting and single-row selection enabled.

    5. changed the property table DisplayRow selected.  No other property has changed.

    When I run the application, the table appears and is filled as expected.  However, after you select at random the rows in the table, the application will lose focus and become hidden behind other applications on my desktop.  If I bring the application in the foreground and try again the same thing will happen.  After the selections of line 1 X application will disappear from the screen.

    I decided to reproduce the JDev 12.1.2 test.  In JDev 12.1.2 the application behaves as expected.  Never, the application loses focus after several attempts to select a field.

    I wonder if something in the hotfix released to correct the 12 c/Internet Explorer 11 questions is the culprit.

    Everyone knows about this problem?  I hope there is a change of ownership that I do in 12.1.3 to solve the problem.

    Thanks in advance!

    A solution that seems to work...

    Add a clientListener inside the table

    
    

    Add a javascript method

    function handleTableSelection() {
      window.focus();
    }
    

    Just seems to bring the window to the front without changing anything, as far as I can tell.

  • Turn off the ADF parasmo tab based on the selection of rows in table

    Hello

    We have page ADF, which consists of a table within a collection of panels, which in turn is inside a Panel tab that user can select several rows in this table. There is also a second tab that you want to activate only if the user has selected a single line in the table. This should be disabled if several lines are selected in the table. Please let me know how this can be accomplished. The selection of multiple rows in the table is a must for users.

    I use jDeveloper 11.1.2.3.0

    Thank you
    Ashwin

    Published by: 989372 on April 24, 2013 08:22

    Hello

    1. set up the table for selection of rows multi
    2. If you initially created the unique selection table, delete the SelectionListener entry added by JDeveloper
    3. create a custom pointing to a managed bean selection listener
    4. in the selection listener, call getComponent on the selection event (http://myfaces.apache.org/trinidad/trinidad-api/apidocs/org/apache/myfaces/trinidad/event/SelectionEvent.html) and cast to richeTableau
    5. on rich table Manager, call getSelectedRowKeys (http://docs.oracle.com/cd/E28389_01/apirefs.1111/e10684/oracle/adf/view/rich/component/rich/data/RichTable.html)
    6. If there is more than one key of the selected row, set a property of a managed bean (for example showTab) false and PPR Panel tab
    7 use the property "off" from the showDetailItem (http://jdevadf.oracle.com/adf-richclient-demo/docs/tagdoc/af_showDetailItem.html) to point to the property Boolean managed bean

    Frank

  • Select the row of the table using radiobutton

    Dear all,

    I want to have a column that will a radiobutton and button in the page. When the user clicks the button, so I want a task by taking the data from the selected row. I kept the rows in the table to a single selection. When the user selects the row (without selecting the radiobutton control), then I can also get the current line and get the data from that. But when the user presses the button (in its actionlistener) then how can I know if the user has selected the radiobutton control or not in the current line.
    Can someone give me guidance in this problem...

    Kind regards
    David

    JDeveloper 11.1.1.4.0

    Santosh,
    where is the property of the value of the bound radio button for? It is an attribute of the line? If so you can access the value via the current line.

    Timo

  • [JS] select multiple rows in a table

    Hi guys,.

    Is it possible to select several lines in a table? If I pass a reference table of the lines to the app.select () method, it fails.

    For that which is ok, but not for two or more. The lines are next to that them not chnge a thing.

    var t = ....tables[0] //a given reference to a table
    app.select([t.rows[1], t.rows[2], t.rows[3]])
    //Error > Expected array of objects but received (Row,Row,Row)
    

    App.Select(t.Rows[1]) works very well. But when I want to select multiple lines, that is not.

    Any advice?

    TIA Loïc

    Hey!

    Try selecting each line separately:

    var myT = app.selection[0].tables[0];
    myT.rows[0].select();
    myT.rows[1].select(SelectionOptions.ADD_TO);
    

    tomaxxi

  • 00497 PLS: do not mix between row and several rows (in BULK) list

    Hello

    I have a requirement to send an array of data via mail,

    so use execute statement after opening the connection and use the following code PLSQL, who is not running.

    My code goes like this.

    0            10            20           30           40            50

    1 CREATE OR REPLACE PROCEDURE SEND_TABLE_DATA (FROMAD IN VARCHAR2,

    2 TOAD IN VARCHAR2,

    3 SUBJECT IN VARCHAR2,

    4 MESSAGE IN VARCHAR2,

    5 DOCID IN VARCHAR2,

    6 DOCDT IN DATE,

    PRODOAID 7 IN NUMBER)

    8 AS

    BATCHNO 9 VARCHAR2 (32767).

    NUMBER OF PCSBOX 10;

    NUMBER AMOUNT 11;

    12 SMTPHOST VARCHAR2 (255): = ' XXX.XXX. X.XXX ";

    13. A UTL_SMTP. CONNECTION;

    BEGIN 14

    15A: = UTL_SMTP. OPEN_CONNECTION(SMTPHOST,25);

    16 UTL_SMTP. HELO (A, SMTPHOST);

    17 UTL_SMTP. MAIL (A, FROMAD);

    18 UTL_SMTP. RCPT (A, TOAD);

    19 UTL_SMTP. OPEN_DATA (A);

    20 UTL_SMTP. WRITE_DATA (ONE, CHR (13) |) CHR (13) | CHR (13));

    21 UTL_SMTP. WRITE_DATA (, ' Date: ' |) TO_CHAR (SYSDATE, ' DD/MM/YYYY HH24:MI:SS'). CHR (13));

    22 UTL_SMTP. WRITE_DATA (, ' from: ' |) FROMAD | CHR (13));

    UTL_SMTP 23. WRITE_DATA (, ' from: ' |) TOAD | CHR (13));

    24 UTL_SMTP. WRITE_DATA (, ' subject: ' |) TOPIC | CHR (13));

    25 UTL_SMTP. WRITE_DATA (ONE, MESSAGE |) DOCID | "Documented on ' | DOCDT | CHR (13));

    26 UTL_SMTP. WRITE_DATA (A, CHR (13) |) CHR (13) | CHR (13));

    UTL_SMTP 27. WRITE_DATA (A, "it's for your information" |) CHR (13));

    28 UTL_SMTP. WRITE_DATA (, ' BATCHNO ' |) ' -- '||' PCSBOX ' |' --' ||' AMOUNT '. CHR (13));

    29 IMMEDIATE EXECUTION

    30 ' SELECT

    31 A.BATCHNO, B.PCSBOX, B.AMOUNT

    32

    33 SCHEMA1. TABLEX, SCHEMA2. TABLEY B

    34. WHERE THE

    35 A.BATCHID = B.BATCHNO AND B.PRODOAID =' | PRODOAID

    36. IN BULK COLLECT INTO BATCHNO, PCSBOX, AMOUNT;

    37 FOR indx IN 1.BATCHNO. COUNTY

    LOOP 38

    UTL_SMTP 39. WRITE_DATA (A, BATCHNO (indx) |) ' -- '|| PCSBOX (indx) |' --' || Amount (indx) | CHR (13));

    40 END LOOP;

    UTL_SMTP 41. WRITE_DATA (A, CHR (13) |) CHR (13) | CHR (13));

    UTL_SMTP 42. CLOSE_DATA (A);

    UTL_SMTP 43. QUIT (A);

    44 EXCEPTION

    45 THEN THAN OTHERS THEN

    UTL_SMTP 46. QUIT (A);

    RAISE 47;

    FIN 48;

    49.

    SELECT * FROM USER_ERRORS

    NAME TYPE SEQUENCE LINE POSITION TEXT ATTRIBUTE MESSAGE_NUMBER

    SEND_TABLE_DATAPROCEDURE3371PL/SQL: Statement ignoredERROR0
    SEND_TABLE_DATAPROCEDURE23724PLS-00487: Invalid reference to the variable 'BATCHNO '.ERROR487
    SEND_TABLE_DATAPROCEDURE1362500497 PLS: do not mix between row and several rows (in BULK) listERROR497

    Thanks in advance

    Concerning

    Pradeep.

    > 29 IMMEDIATE EXECUTION

    > 30 ' SELECT

    > A.BATCHNO, B.PCSBOX, B.AMOUNT 31

    > 32 OF

    > 33 SCHEMA1. TABLEX, SCHEMA2. TABLEY B

    > WHERE 34

    > A.BATCHID = 35 B.BATCHNO AND B.PRODOAID =' | PRODOAID

    > 36 BULK COLLECT INTO BATCHNO, PCSBOX, AMOUNT;

    BATCHNO PCSBOX and AMOUNT variables are defined as scalar variables. Check the definition here

    > 9 BATCHNO VARCHAR2 (32767).

    NUMBER OF PCSBOX > 10;

    > 11 AMOUNT NUMBER;

    You cannot use COLLECT LOOSE on scalar variables. The variables must be defined as a TYPE of COLLECTION to make in bulk to collect.

  • How to get the cursor to the first line after the addition of 3 rows in the OPS. Help, please.

    Hi Experts,

    I have a requirement to get the cursor should point to the first line instead of pointing to the third row. To the help of code below, my cursor points to the third row. Please put some light on it to reach the requirement

    XXCLKTestVOImpl vo = getXXCLKTestVO1();

    for (int i = 0; i < 3; i ++) {}

    Line = vo.createRow ();

    vo.insertRow (row);

    row.setNewRowState (Row.STATUS_INITIALIZED);

    }

    Thank you

    Gurnur Singh

    Problem is solved. Since then, I've been on 12.2.4 Ebs version and was auto insert false setting in AddtablerowBean. To reach the requirement, you will need to refer to the same number of lines to add the addtablerowbean property that you use in loop for. here I use 3 looping so you must use the number 3 lines to add the addtablerowbean property to get there. So whenever you add three rows then cursor in the first row of three lines you will add. Thank you all.

    Thank you

    Gurnur Singh

  • Hello! Is it possible to convert a trace made with the Brush tool a blob in a simple brush trace (a simple vector line - not two lines with a filling in between)? Thank you very much for your help!

    Hello!

    Is it possible to convert a trace made with the Brush tool a blob in a simple brush trace (a simple vector line - not two lines with a filling in between)? Thank you very much for your help!

    No, I don't think.

  • selection of rows in table

    I know this was asked (I read all the other posts on the same question), but I have no luck with the 'official' way to do it.

    I'm doing a row of a table (in hot mode) to become selected if you click on one of its cells.  Here is my point:

    int CVICALLBACK TableTest (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
    {
        Point cell;
    
        switch (event)
        {
            case EVENT_LEFT_CLICK:
                GetTableCellFromPoint(panel,control,MakePoint(eventData2,eventData1),&cell);
                if (cell.x == 0 && cell.y == 0) return 1; // Not on a row/col
                SetTableSelection(panel,control,VAL_TABLE_ROW_RANGE(cell.y));
                break;
        }
        return 0;
    

    What I see, is that the just SetTableSelection is not what it is supposed to do.  I can break the function to the GetTableCellFromPoint and I can see the line concerned implement cell.y, but then selecting the line fails.

    I found a good comment on the other thread about the mode of control of the table.  This poster pointed out that, if the table is in non-indicateur mode, my reminder must swallow the event.  OK, I tried and it works somehow.  I can see the selected line, but it's a strange effect highlighted, not a dark solid grey cell background. See attachment (I've highlighted the line that was clicked).

    Which leads to more questions.  On a hot table, with traditional events which don't are NOT swallowed, event that creates the selection dark grey background of a cell?

    To smile, I also tried to put my table saw mode and do not swallow all of the events. But here there is no selection at all.

    So I'm just very confused about this.  What I am doing wrong?

    I don't think you're doing something wrong, apart from the fact that you're not swallowing the event when you change the selection. But even if your code does not she, you said that you have done this anyway, so it's probably a moot point.

    On the other hand, I don't think you need to swallow the event when the user clicks on a row or column. As your reminder override mouse click in this case, I think you should allow the table to manage the event. Also, I think that your condition should be (cell.x == 0 | cell.y == 0) instead - the difference between the two conditions occurs when the user clicks on a row or column header and the table must already do what you want it to do in this case.

    The only reason that you see the outline instead of the inversion of color is because it's as if the table is not the active control in the Panel. And that's how all the table selections are drawn when the table is not the focus. If you tab through the table, after you change the selection is not the change of plans? In addition, if you try to run a program example with a table (for example, samples\userint\gridview.prj). As you move the selection of this table and then tab away from the control, can't the same thing?

    Luis

  • Select the row column report default tick intractive all

    Dear friends,


    SELECT LINE intractive report column check box should be checked by default. If I want to uncheck in this column of the select row I could do.

    How can I do this?




    Concerning

    CORINE

    Hi Maxence,

    CORINE wrote:

    Hello

    I used this link http://carlback.blogspot.com/2007/09/mini-check-all-howto.html

    Classic report. in the case of column intractive automatic report check box created at the top of the report to update and remove number of lines and the column named as the selected lines. I want intractive report this column box to checked by default. now which albums happed checkbox header column is unchecked while on this it is TICKING at all under the values checkbox. I want to check all values for first time during the page load.

    Hope I am clear to you the obligation.

    Still not clear with the wording of the explanation. I understand that there is an interactive relationship with the first column as a box to tick and the loading of the page you want all the boxes ticked.

    To make this writing a dynamic action on the page load to run some JavaScript as follows:

    $( "input:checkbox" ).attr('checked', true);
    

    But this applies to all of the check boxes on the page. If you want more specific a class say chkbox adds the checkbox column and change the dynamic action above to:

    $( ".chkbox" ).attr('checked', true);
    

    I hope this helps!

    Kind regards

    Kiran

  • Toggle the button toolbar on the selection of rows in table

    Hi all
    I have a problem with activation and deactivation of the toolbar button when the table row is selected... Here's the deal:

    I have a toolbar button named "activate" I want to activate only when the selected table line has say for example 'description' field is not empty. I'm looking for a solution so that I can say declaratively:

    < disabled af:commandToolbarButton = "#{I'M looking FOR THIS CASE =="} "/ >"

    I tried using #{bindings.activateAttributeFromSameIterator} thinking that when the selection on the row in the table is changed, the change is reflected also and I will get the result, but without success (that link was nothing)... I also updated partialTriggers this toolbar button.


    I would appreciate if anyone can shed some light on this...

    Thank you

    Hello

    create a binding of the attributeValue to the descriptor field using the "Bindings" tab in the Visual Editor. In the connections section, click the Green plus icon, choose generic and attributeValue Bindings are included. Select the iterator used by the table and select the attribute "descriptor" (the name of the attribute that you mentioned). Then change

    TO

    Frank

  • Select the rows with values max.

    SELECT MOFFER.DELIVERYPURCHASE,
      MOFFER.OFFERSTART,
      MOFFER.OFFEREND,
      MOFFER.RANKING,
      MMTDEMANDBID.BALANCEGROUPPK
    FROM EMTMOFFER MOFFER
    INNER JOIN MMTDEMANDBID ON MOFFER.OFFERID = MMTDEMANDBID.MMTDEMANDBIDPK
    WHERE MOFFER.DELIVERYPURCHASE = 'P'
    AND MOFFER.OFFERSTART        >= '2012-01-18T00:00:00'
    AND MOFFER.OFFEREND          <= '2012-01-19T00:00:00'
    AND MMTDEMANDBID.BALANCEGROUPPK = '10393'
    DELIVERYPURCHASE OFFERSTART          OFFEREND            RANKING                BALANCEGROUPPK         
    ---------------- ------------------- ------------------- ---------------------- ---------------------- 
    *P                2012-01-18T23:00:00 2012-01-19T00:00:00 2                      10393*                  
    P                2012-01-18T23:00:00 2012-01-19T00:00:00 3                      10393                  
    P                2012-01-18T00:00:00 2012-01-18T01:00:00 2                      10393                  
    P                2012-01-18T01:00:00 2012-01-18T02:00:00 2                      10393           
    *P                2012-01-18T02:00:00 2012-01-18T03:00:00 1                      10393*         
    P                2012-01-18T02:00:00 2012-01-18T03:00:00 2                      10393                  
    P                2012-01-18T03:00:00 2012-01-18T04:00:00 2                      10393                  
    P                2012-01-18T04:00:00 2012-01-18T05:00:00 2                      10393                  
    *P                2012-01-18T05:00:00 2012-01-18T06:00:00 1                      10393*
    P                2012-01-18T05:00:00 2012-01-18T06:00:00 2                      10393                  
    P                2012-01-18T06:00:00 2012-01-18T07:00:00 2                      10393                  
    P                2012-01-18T07:00:00 2012-01-18T08:00:00 2                      10393                  
    P                2012-01-18T08:00:00 2012-01-18T09:00:00 2                      10393                  
    P                2012-01-18T09:00:00 2012-01-18T10:00:00 2                      10393                  
    P                2012-01-18T10:00:00 2012-01-18T11:00:00 2                      10393                  
    P                2012-01-18T11:00:00 2012-01-18T12:00:00 2                      10393                  
    P                2012-01-18T12:00:00 2012-01-18T13:00:00 1                      10393                  
    P                2012-01-18T13:00:00 2012-01-18T14:00:00 1                      10393                  
    P                2012-01-18T14:00:00 2012-01-18T15:00:00 1                      10393                  
    P                2012-01-18T15:00:00 2012-01-18T16:00:00 2                      10393                  
    P                2012-01-18T16:00:00 2012-01-18T17:00:00 2                      10393                  
    P                2012-01-18T17:00:00 2012-01-18T18:00:00 2                      10393                  
    P                2012-01-18T18:00:00 2012-01-18T19:00:00 2                      10393                  
    P                2012-01-18T19:00:00 2012-01-18T20:00:00 2                      10393                  
    P                2012-01-18T20:00:00 2012-01-18T21:00:00 2                      10393                  
    P                2012-01-18T21:00:00 2012-01-18T22:00:00 2                      10393                  
    P                2012-01-18T22:00:00 2012-01-18T23:00:00 2                      10393                  
     27 rows selected 
    Help, please. How to select lines with RANKING max, OFFERSTART and OFFEREND if the same.
    Get 24 ranks. One for every hour.

    SELECT MOFFER. DELIVERYPURCHASE,
    MOFFER. OFFERSTART,
    MOFFER. OFFEREND,
    Max (MOFFER. (Rank CLASSIFICATION),
    MMTDEMANDBID. BALANCEGROUPPK
    OF EMTMOFFER MOFFER
    INNER JOIN MMTDEMANDBID ON MOFFER. OFFERID = MMTDEMANDBID. MMTDEMANDBIDPK
    WHERE MOFFER. DELIVERYPURCHASE = 'P '.
    AND MOFFER. OFFERSTART > = ' 2012 - 01-18T 00: 00:00'
    AND MOFFER. OFFEREND<=>
    AND MMTDEMANDBID. BALANCEGROUPPK = '10393'
    Group of MMTDEMANDBID. BALANCEGROUPPK, deliverypurchase, offerstart, offerend

  • How to select a row in a table of adf after double click

    I have a table that displays a list of records when the user double-clicks a particular line, I want to select row. The largest part of the example has a separate button for the user to click on choose and I don't want that.

    Hello

    On your table have a clientListener and a serverListener:


         
         


    ....

    Your clientListener should send a request to the server using AdfCustomEvent.queue:

    function dblClickClientLstnr (event) {}
    element var = event.getSource (event);
    AdfCustomEvent.queue (element, "dblClickServerLstnr", (), true);

    }
    ..............

    On your support of bean, you can retrieve the selected line, for example:

    {} public void getSelectRow (ClientEvent clientEvent)

    DCBindingContainer dcBindings = (DCBindingContainer) ADFUtils.getBindingContainer ();
    DCIteratorBinding iterBind = (DCIteratorBinding) dcBindings.get ("myViewIter");
    Line = iterBind.getCurrentRow ();

    }

    I hope this helps.

  • How to select only rows with multiple records below?

    Dear all,

    My Table looks at below:

    Table structure:
    CREATE TABLE T_20 (CONTROL NUMBER(10) NOT NULL,
                           PO NUMBER(10) NOT NULL,
                           AMENDNO NUMBER(3) NOT NULL,
                           FACTOR VARCHAR2(3) NOT NULL,
                           COMMENT_X VARCHAR2(40),
                           FLAG VARCHAR2(1))
    
    
    SQL> alter table t_20 add constraint t_20_pk primary key (control, po, amendno, factor);
    INSERT orders:

    SQL> INSERT INTO T_20 VALUES(101,1000,01,'MSC','NO COMMENT','Y')
      2  /
    
    1 row created.
    
    SQL> INSERT INTO T_20 VALUES(101,1000,02,'MSC','NO COMMENT','Y')
      2  /
    
    1 row created.
    
    SQL> INSERT INTO T_20 VALUES(101,1001,00,'NDP','NO COMMENT','Y')
      2  /
    
    1 row created.
    
    SQL> INSERT INTO T_20 VALUES(101,1001,01,'NDP','NO COMMENT','Y')
      2  /
    
    1 row created.
    
    SQL> INSERT INTO T_20 VALUES(102,1002,00,'ABC','NO COMMENT','Y')
      2  /
    
    1 row created.
    out put:
    SQL> SELECT * FROM T_20
      2  /
    
       CONTROL         PO    AMENDNO FAC COMMENT_X                                F 
    ---------- ---------- ---------- --- ---------------------------------------- - 
           101       1000          1 MSC NO COMMENT                               Y 
           101       1000          2 MSC NO COMMENT                               Y 
           101       1001          0 NDP NO COMMENT                               Y 
           101       1001          1 NDP NO COMMENT                               Y 
           102       1002          0 ABC NO COMMENT                               Y 
    Now, I want to select only the control number that have several acht.

    In above example only control 101 with several PO 2 PO with 1000 and 1001
    So I need to select only this 101 related lines...

    for 102 having in. sinple folders then it will have to be removed... because I have millions of records in the primary table...
    someone you suggest query... Thank you..

    Thanks in advance
    Prasanth

    Try this

    select *
      from (
    select t.*, count(distinct po) over(partition by control) cnt
      from t_20
          )
     where cnt > 1
    

Maybe you are looking for