How to select rows

Hi all,
How to select distinct rows without using distinct,unique key word.
When ever i use distinct key word oracle database is hanging ..
regards
prakash

How to select distinct rows without using distinct,unique key word.
When ever i use distinct key word oracle database is hanging ..The database isn't 'hanging'. It just needs more time than you want to do what you asked it to do.
The standard counter-questions are:
- why do you need a distinct (or group by)?
- could it be that your datamodel needs some adjustments?
- how many rows are you expecting?
- how many rows are you selecting from?
- what does the query look like?
- what database version are you working with (the result of: select * from v$version; ) ?
There is no substitute for DISTINCT|UNIQUE (or GROUP BY), you should really think about why you need a DISTINCT in the first place, since it's killing the performance of the database in the first place, especially on (very) large sets.
Since you're actually having a performance problem, I suggest you read:
HOW TO: Post a SQL statement tuning request - template posting
and post all relevant details you've left out so far.

Similar Messages

  • How to select rows in adf faces table

    Hi guys
    im new to adf faces .I created a adf faces table with some data.My task is to select one row and if i click tht row, the data of tht row will be displayed in an input text fileds.How can i select a row in a adf faces table and give actions to rows...i read so many tutorials...none of them didnt give a correct idea....plz help me...
    thanks in advance..
    rajiv

    You're here in the Sun JSF forum, not in the Oracle JSF forum.
    Try here: JDeveloper and ADF
    If the ADF datatable is technically comparable with the RI datatable, check http://balusc.xs4all.nl/srv/dev-jep-dat.html to get some insights how to retrieve the selected row object.

  • How to select rows in the inner JTable rendered in an outer JTable cell

    I have wrriten the following code for creating cell specific renderer - JTable rendered in a cell of a JTable.
    table=new JTable(data,columnNames)
    public TableCellRenderer getCellRenderer(int row, int column)
    if ((row == 0) && (column == 0))
    return new ColorRenderer();
    else if((row == 1) && (column == 0))
    return new ColorRenderer1();
    else
    return super.getCellRenderer(row, column);
    ColorRenderer and ColorRenderer1 are two inner classes, which implement TableCellRenderer to draw inner JTable on the outer JTable cell, having 2 rows and 1 column each.
    Now what is happening the above code keeps executing continously, that is the classes are being initialised continously, inner JTables are rendered (drawn) continously, and this makes the application slow after some time. It throws java.lang.OutOfMemoryException.
    WHY IS IT SO??? I can't understand where's the bug..
    Any advice please???
    Moreover i want selections in inner tables and not on outer table, how can this be possible.
    I am working on this since a long time but have not yet found a way out...

    With your help i have overcome the problem of continous repeatition.
    The major problem which I am facing is, in selecting rows in the inner rendered JTables.
    I have added listener on outer JTable which select rows on the outer JTable, hence the complete inner JTable which being treated as a row, gets selected.
    The thing is i need to select the rows of inner rendered JTables,not the outer JTable.
    How to go about it??
    I have even added listener to inner rendered JTables, but only first row of every table gets selected.
    Please help....
    Thanks in advance.

  • How to select rows from database like 10 to 20 etc

    Hi Experts,
    I want to select rows from database like row number 10 to row number 20.How could it be done?

    HI,
       First get the data into the INTERNAL TABLE from the FLAT FILE and read the internal table using the index.
        ex: 1) Read table ITAB index 10.
              2) Read table ITAB index 20.
    or use as said by  Srinivas Gurram, to get the range of records using where condition to the loop.
    <REMOVED BY MODERATOR>
    Edited by: Ravi Kumar on Jun 9, 2008 4:01 PM
    Edited by: Alvaro Tejada Galindo on Jun 9, 2008 3:16 PM

  • How to select rows in this way ?????

    Hi All,
    How to select tables from 2 table say client and vendor. Both have id, name. Now I want data of two tables using union but the data of one table come after another.
    select id,name from vsg.client union select id,name from vsg.vendor
    Eg.
    Vendor Client
    ID Name ID Name
    1 ab 12 xyz
    2 cd 13 wyx
    3 ef 14 pqr
    Now output should come like this
    ID Name
    1 ab (First rows from Vendor)
    2 cd
    3 ef
    12 xyz (second rows from Client)
    13 wyx
    14 pqr
    Thanks for your reply in advance......

    NO this one is not workingWhy not? Are you using some ancient version of Oracle?
    SQL> create table vendor
      2  as
      3  select 'v1' id, 'a' name from dual union all
      4  select 'v3', 'c' from dual union all
      5  select 'v2', 'b' from dual
      6  /
    Tabel is aangemaakt.
    SQL> create table client
      2  as
      3  select 'c1' id, 'd' name from dual union all
      4  select 'c3', 'f' from dual union all
      5  select 'c2', 'e' from dual union all
      6  select 'c4', 'g' from dual
      7  /
    Tabel is aangemaakt.
    SQL> select id
      2       , name
      3    from ( select id
      4                , name
      5                , 1 x
      6             from vendor
      7            union all
      8           select id
      9                , name
    10                , 2
    11             from client
    12         )
    13   order by x
    14       , id
    15  /
    ID N
    v1 a
    v2 b
    v3 c
    c1 d
    c2 e
    c3 f
    c4 g
    7 rijen zijn geselecteerd.Regards,
    Rob.

  • How to select row automatically in matrix (exp:automatic select row no 2)?

    Hi
    example i fill matrix row no 1 - 3 in serial number selection form or else (from database data)
    and i want to automatic select row no 2
    and i really have a big problem to do this
    oQuant = edit text
    oColumn = column
    oForm = form
    here some of my code
    ====================================
    formID = pVal.FormUID
    Set oForm = SBO_Application.Forms(formID)
    Set oMatrix3 = oForm.Items.Item("5").Specific
    Set oColumn3(3) = oMatrix3.Columns.Item("19")
    Set oQuant(5) = oColumn3(3).Cells.Item(2).Specific
    =====================================
    i tried
    oMatrix3.SelectRow 2, True, False
    but it didn't work , it's said that not user defined item
    oQuant(5).Active = True
    it works but that not the select what i want
    pls some one help me
    i really need it right away
    Thanks

    Hi chetan
    Thank You for your reply and yes i didn't write selection mode for my matrix
    but when i tried both of these code it still didn't work (for information i'm using visual basic 6, so it has a different syntax about .net and VB6 - exp: for .net  oMatrix.selectrow(2,true,false) , for VB6 oMatrix.selectrow 2,true,false )
    oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Auto
    oMatrix.SelectRow 2, True, False
    oMatrix.SelectionMode = ms_Auto
    oMatrix.SelectRow 2, True, False
    is there any presiquities for selection mode ?? because I always have <b>warning</b> on oMatrix.selectionmode
    "<b>Item - the item is not user defined item</b>"
    Edit : it works when i created a form and select row no 2,  but it didn't work with serial number selection form which the form is already exist in SBO (serial number selection is the form after klik add button in good issue form)
    Thanks

  • How to select  rows with duplicate column values

    hi,
    i have a table property_details which has these 2 columns customerno and propertyno a customer can have many properties and property number has to be unique. but somehow these property number has been duplicated at an earlier stage so i have for a customer with many properties the same property number
    how i will select such records whose asset numbers are the same
    for ex
    customer no property no
    a1300 1
    a1300 1
    a1300 1
    a2330 10
    a2330 10
    a2330 10
    kindly suggest me a solution

    this example might be of help.
    SQL> select * from employees;
    YEAR EM NAME       PO
    2001 02 Scott      91
    2001 02 Scott      01
    2001 02 Scott      07
    2001 03 Tom        81
    2001 03 Tom        84
    2001 03 Tom        87
    6 rows selected.
    SQL> select year, empcode, name, position,
      2         row_number() over (partition by year, empcode, name
      3                            order by year, empcode, name, position) as rn
      4    from employees;
    YEAR EM NAME       PO         RN
    2001 02 Scott      01          1
    2001 02 Scott      07          2
    2001 02 Scott      91          3
    2001 03 Tom        81          1
    2001 03 Tom        84          2
    2001 03 Tom        87          3
    6 rows selected.
    SQL> Select year, empcode, name, position
      2    From (Select year, empcode, name, position,
      3                 row_number() over (partition by year, empcode, name
      4                                    order by year, empcode, name, position) as rn
      5            From employees) emp
      6   Where rn = 1;
    YEAR EM NAME       PO
    2001 02 Scott      01
    2001 03 Tom        81
    SQL>

  • How to select rows which starts with

    In the below example I want only the rows which starts with the word CERTIFICATE.
    How do we do?
    create table full_text(text clob);
    insert all
    into full_text values('CERTIFICATE OF SERVICE')
    into full_text values('APPLICATION FOR CERTIFICATE')
    into full_text values('CERTIFICATE OF LIABILITY')
    into full_text values('CERTIFICATE OF TITLE')
    SELECT * FROM DUAL ;
    COMMIT;
    CREATE INDEX CTX_INDX_TEXT ON full_text (TEXT) INDEXTYPE IS CTXSYS.CONTEXT;
    SQL> select * from full_text where contains(text,'$CERTIFICATE')>0 ;
    TEXT
    CERTIFICATE OF TITLE
    CERTIFICATE OF LIABILITY
    APPLICATION FOR CERTIFICATE
    CERTIFICATE OF SERVICE
    The 3rd row show not appear.
    Thanks

    I understand what Roger is saying. Since it is past his bedtime there in the UK and still sunny here in California, here is an example for you:
    SCOTT@orcl_11g> create table full_text(text clob)
      2  /
    Table created.
    SCOTT@orcl_11g> insert all
      2  into full_text values('CERTIFICATE OF SERVICE')
      3  into full_text values('APPLICATION FOR CERTIFICATE')
      4  into full_text values('CERTIFICATE OF LIABILITY')
      5  into full_text values('CERTIFICATE OF TITLE')
      6  SELECT * FROM DUAL
      7  /
    4 rows created.
    SCOTT@orcl_11g> CREATE OR REPLACE PROCEDURE your_proc
      2    (p_rowid IN           ROWID,
      3       p_clob     IN OUT NOCOPY CLOB)
      4  AS
      5  BEGIN
      6    FOR r IN
      7        (SELECT text
      8         FROM      full_text
      9         WHERE  ROWID = p_rowid)
    10    LOOP
    11        DBMS_LOB.WRITEAPPEND (p_clob, 8, 'XXSTART ');
    12        DBMS_LOB.APPEND (p_clob, r.text);
    13        DBMS_LOB.WRITEAPPEND (p_clob, 6, ' XXEND');
    14    END LOOP;
    15  END your_proc;
    16  /
    Procedure created.
    SCOTT@orcl_11g> SHOW ERRORS
    No errors.
    SCOTT@orcl_11g> BEGIN
      2    CTX_DDL.CREATE_PREFERENCE ('your_datastore', 'USER_DATASTORE');
      3    CTX_DDL.SET_ATTRIBUTE ('your_datastore', 'PROCEDURE', 'your_proc');
      4    CTX_DDL.SET_ATTRIBUTE ('your_datastore', 'OUTPUT_TYPE', 'CLOB');
      5  END;
      6  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11g> CREATE INDEX CTX_INDX_TEXT ON full_text (TEXT) INDEXTYPE IS CTXSYS.CONTEXT
      2  PARAMETERS ('DATASTORE your_datastore')
      3  /
    Index created.
    SCOTT@orcl_11g> select * from full_text where contains(text,'XXSTART $CERTIFICATE')>0
      2  /
    TEXT
    CERTIFICATE OF SERVICE
    CERTIFICATE OF LIABILITY
    CERTIFICATE OF TITLE
    SCOTT@orcl_11g>

  • How to select rows whose one column contains some specific characters ?

    These is a table say T1 with a column say C1
    Let the field C1's values be:
    row 1)DE/SPT/A/FWD
    row 2)G/SPT/DE/DE/SPT
    row 3)R/FWD/SPT/A/FWD/FWD
    row 4)A/A/DE/SPT/FWD
    row 5)FWD/SPT/E/DE/A
    How to get only those rows whose C1 column contains FWD in last ?

    We can solve this with the simple use of a wildcard:
        select *
        from t1
        where c1 like '%FWD'
        /Note that this query will execute a full table scan, because any index you may have on C1 will be ignored: indexes are organised on the leading characters.
    cheers, APC

  • How to select rows or columns of tables without using the mouse?

    2nd post ever! Yeah! \m/
    In Excel, I can select entire rows or columns of data WITHIN TABLES--i.e., not selecting entire sheet rows or columns--by going to any cell on the perimeter of the table, holding down shift+ctrl, and clicking a direction arrow. So for example, if I have a table in columns D-G and rows 1-5, I can highlight row 4 by going to the first or last cell of that row, holding down the shift+ctrl, and hitting the appropriate direction arrow. You might think this is superfluous given that you can use the mouse to select cells. But that becomes cumbersome with large tables, and this method can be more efficient even with small tables.
    Similarly, it's often useful to navigate tables, particularly large ones, by moving from any cell within the table to the end or beginning of that row or column by holding down ctrl and hitting the appropriate arrow key. In Excel, this ctrl+arrow key method also allows you to skip blank cells, which is another very useful navigational feature.
    I tried numerous combos involving shift, ctrl, command, alt/option and the arrow keys. Haven't found a way to do any of this yet.
    Anyone?

    Hi Josh,
    Numbers is organized differently than Excel, and the navigation tools are different too. Many of us miss our particular favorites from spreadsheets past, but this is Numbers, not a clone. The biggest adjustment is to go from huge monolithic sheet-tables containing virtual sub-tables to a simple blank sheet with small tables, sometimes many per sheet. Navigating is no big deal in these small tables and neither is getting from one small table to another, using the Sheets pane.
    Selecting a particular Table is as easy as clicking on the table's name in the Sheets pane. Selecting a particular row, or column, or ranges of rows or columns is done by clicking on the table's row and column labels, left side and top side once a cell is selected in the table.
    Numbers is weak at handling large Tables and documents that are large overall. We know this and many of us still prefer it to the alternative when the tool fits the task.
    Jerry

  • How to select rows based on values from other table?

    I need to select all rows from TABLE1 whose time column is NOT between fromTime and toTime from TABLE2.
    For example, those table contain following rows:
    TABLE1
    |id |time |...
    |1 | 10 |...
    |2 | 20 |...
    |... | ... |...
    TABLE2
    |fromTime|toTime|
    | 3 | 6 |
    | 10 | 16 |
    | 20 | 25 |
    So, in the case above the first and second rows shouldn't be returned by the query since 10<=10<=16 AND 20<=20<25.

    Try
    -- code #1
    SELECT id, time
    from TABLE1 as T1
    where not exists (SELECT * from TABLE2 as T2
    where T1.time between T2.fromTime and T2.toTime);
    José Diz     Belo Horizonte, MG - Brasil

  • How to select rows with Empty Column Entry

    I am trying to select all rows with an empty column
    select row1 from table where row2=' ';
    Any suggestions. I tried a space and no space in between the ''.

    An (theoretical) argument could be made that an empty string is not NULL (uknown), however Oracle's SQL and PL/SQL engines make no such distinction for VARCHAR2 and CHAR data types. As stated, you must use NULL as the comparison.
    Michael

  • Select / how to select row that meet only  one of select-options

    Hello ,
    I am developing rapport in release 6.0.
    On the screen I have three  select -options  s1 , s2 , s3
    I db table I have several entries with values in f1 f2  and f3
    f1 f2 f3
    1 | 2 |
    3 | 4 |
    5 | 6 |
    a | b | c
    When I enter  , on screen  1 in S1 , and  c in f3 i do not get any data in internal table . Obviously program is looking
    for  the row that satisfies   both criteria .
    My question is what would be the way to get for same screen entry  all row satisfying firs criteria and all lines satisfying
    second criteria independently . SO i would like to have  row 1|2 and row a|b|c if user enters , value "1" in s1 and value "c" in s3.
    Thanks
    source code .
    select * from db_tab
    into corresponding fields of table Itab
    where f1 in  s1 and
                f2 in  s2  and
                f3 in  s3.

    Hello ,
    I was thinkinf of OR  , but i doesnt work .
    When use  enter only S3 and leave empty S1 the resul will be  ALL entries from db table .
    S1 = initial
    S = c
    result is
    1|2
    3|4
    5|6
    a|b|c
    Thank you

  • How to select rows with min value on a specific column

    I have a query:
    select
      m.x1,
      round (to_date (l.y1, 'mm/dd/yyyy HH:MI:SS AM') - m.x2, 0) as numofdays
    from
      table1 m,
      table2 l
    where
      l.x3 = m.x3 and
      to_date (l.y1, 'mm/dd/yyyy HH:MI:SS AM') >= TO_DATE('01012013','MMDDYYYY') and
    and I got this result table:
    x1 (ID)
    numofdays
    001
    5
    001
    10
    002
    2
    003
    3
    003
    1
    004
    0
    005
    66
    several ID's have multiple values on the second column, I want to have only distinct IDs with smallest "numofdays" like this:
    x1 (ID)
    numofdays
    001
    5
    002
    2
    003
    1
    004
    0
    005
    66
    Any ideas?

    Hi,
    The most general and versatile way is a Top-N Query:
    WITH   got_r_num AS
        select
                m.x1,
                round (to_date (l.y1, 'mm/dd/yyyy HH:MI:SS AM') - m.x2, 0) as numofdays
        ,       ROW_NUMBER () OVER ( PARTITION BY  m.x1
                                     ORDER BY      to_date (l.y1, 'mm/dd/yyyy HH:MI:SS AM') - m.x2
                                   )  AS r_num
        from 
              table1 m,
              table2 l
        where
              l.x3 = m.x3 and
              to_date (l.y1, 'mm/dd/yyyy HH:MI:SS AM') >= TO_DATE('01012013','MMDDYYYY') and
    SELECT  x1, numofdays
    FROM    got_r_num
    WHERE   r_num   = 1
    If you'd care to post CREATE TABLE and INSERT statements for your sample data, then I could test it.
    Notice that the sub-query (got_r_num) is exactly what you posted, only with a new column (r_num) added to the SELECT clause.

  • How to get selected row data of an ADF table in HashMap?

    Hi,
    Can anyone please tell me how to selected row data of an ADF table in HashMap like :
    Object obj = pageTable.getSelectedRowData();
    JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)obj;
    Now in above code I want the convert rowData in HashMap.
    Can anyone please tell me how to do that? Its urgent.
    Thanks,
    Vik

    Vik,
    No need to ask the same question 3 times...
    In [url http://forums.oracle.com/forums/message.jspa?messageID=4590586]this post, Nick showed you how to get the Row.
    If it were so urgent, you could have done a little reading of the javadocs to come up with code like this (not tested, up to you to do that)
    HashMap m = new HashMap();
    Row r = get it like Nick showed you to;
    Object values[]=r.getAttributeValues();
    String names[]=r.getAttributeNames();
    for (int i=0; i<r.getAttributeCount(); i++)
    m.put(names, values[i]);

Maybe you are looking for

  • Difference between IS and AS in procedure?

    difference between IS and AS in procedure?

  • When I use internet banking I keep getting servey popups how do I stop this please, Thankyou

    The URL of the popups vary, the last one I have is listed below. Only seems to happen when using Bank web sites. http://consumersurvey-uk.extra-daily.com/?s1=.co-operativebank.co.uk&s2=166

  • Problem in date compare

    Hi All, I have two oracle servers both are 9i. In one machine the date comparison is working file in another its not. I have come up with a sample pl/sql block which is DECLARE STARTDATE DATE; BEGIN STARTDATE := TO_DATE('08/09/2010','mm/dd/yyyy'); --

  • Handling korean charset  in Query string

    I'm testing final release of S1AS7 SE. When a query string is urlencoded, parameter value using korean charset was properly processed. When not urlencoded, parameter value using korean charset was broken. Though Tomcat4 returns correct value. S1AS an

  • Acrobat Pro Crash with Flash Import

    Every time I try to import a Flash file with the Flash tool in Acrobat Pro v9.2.0 it crashes out. i thought it might have been a file size issue but it happens regardless of the size of the file I am trying to import. I'm running 10.6.1 on a MacBook