Select the duplicate rows, based on a combination of columns as the key

Hello

I have a table with 5 columns.

Code ID S_DATE E_DATE name
1 23 01012001 null ABC
1 09 01012001 null XYZ
2 81 04022007 null TVU
1 43 03092008 null XXX



Now, I need to write a select statement to extract the lines duplicated in the table above with the combination of (Code, S_DATE, E_DATE) as the key.
So in the above example, I need to get Row1 and Row2 as output (but not Row3 as she has a different S_DATE)

Thanks in advance for your suggestions.

Thank you

Published by: thotaramesh on March 9, 2009 16:54

The XE;

WITH sample_data AS (
   SELECT 1  code,23 ID, '01012001' s_date, null e_date, 'ABC' NAME FROM dual UNION ALL
   SELECT 1, 09, '01012001', null, 'XYZ' FROM dual UNION ALL
   SELECT 2, 81, '04022007', null, 'TVU' FROM dual UNION ALL
   SELECT 1, 43, '03092008', null, 'XXX' FROM dual)
SELECT code, ID, s_date, e_date, NAME
FROM (
   SELECT
      sample_data.*,
      COUNT(*) over (PARTITION BY code, s_date, e_date) dups
   FROM sample_data)
WHERE dups > 1;

      CODE         ID S_DATE   E_DATE NAME
---------- ---------- -------- ------ ----
         1         23 01012001        ABC
         1          9 01012001        XYZ

Tags: Database

Similar Questions

  • SQL - remove duplicate lines based on date or another column column

    Hello people, it is possible to select the last row by column for a query:

    say that my query returns:

    book_id, date, price
    ===========
    19, 10-JAN-2012, 40
    19, 16-MAY-2012, 35
    18, 10-MAY-2012, 21

    And I want him back

    book_id, date, price
    ===========
    19, 16-MAY-2012, 35
    18, 10-MAY-2012, 21

    In other words, book_id 19 appears twice at the beginning but I now come back to the last version of it (based on the date column) as well as all other lines that have no duplicates.
    Is it possible to do?
    Thank you very much

    Hello

    Here's one way:

    WITH  got_r_num     AS
    (
         SELECT     table_x.*
         ,     ROW_NUMBER () OVER ( PARTITION BY  book_id
                                   ORDER BY          dt     DESC     NULLS LAST
                                 ) AS r_num
         FROM    table_x
    )
    SELECT     *     -- or list all columns except r_num
    FROM     got_r_num
    WHERE     r_num     = 1
    ;
    

    If the combination (book_id, dt) is unique, then you can also use the LAST aggregate function.

  • Query - restrict lines based on specific combinations of columns

    I have two columns of two different T1 and T2 tables as below

    T1. Column1 T2. Column2
    ------------ ---------------
    1 a
    2B
    3 C
    4 D
    5 e

    I need all combinations of values in the columns, which I can choose as

    Select T1. Column1, T2. Column2 from T1, T2-(without specifying a join ie. Cartesian product)

    But in those, combinations, I need to restrict the following combinations, not being selected - (1B), (1, c),(3,b), in the same sql, or by using a subquery. I am not able to achieve after several attempts. Can someone help?

    Simply pad and check

    SQL> select no,name from a,b where to_char(no)||name not in ('1b','1c','3b')
      2  /
    
            NO N
    ---------- -
             1 a
             1 d
             1 e
             2 a
             2 b
             2 c
             2 d
             2 e
             3 a
             3 c
             3 d
    
            NO N
    ---------- -
             3 e
             4 a
             4 b
             4 c
             4 d
             4 e
             5 a
             5 b
             5 c
             5 d
             5 e
    

    Thank you
    Knani.

  • L50-B-2FN satellite: select the keys on the keyboard does not

    Hello

    I have a Satellite L50-B-2FN, bought just five months ago (February 2, 2016), and apart from a problem recurring with the lid doesn't close does not correctly, I now have a hardware problem: the keyboard stopped working fully, with most of the numbers keys does not respond as well as the letters R and Y.

    I checked the keyboard configuration and drivers via Device Manager and the computer tells me that everything is working properly and updated, but this is clearly not the case. I tried Toshiba's own online recommendations: uninstall the keyboard (http://support.toshiba.com/support/t...TYPE=COMPUTERS) and a restoration of the system to the last automatic (http://forums.toshiba.com/t5/System-...10/ta-p/657989), but neither solves the problem.

    What I understand online forums, like thi keyboard problems are a problem common _very_ Toshiba satellites, especially those running (or update of) Windows 10 (mine came with Windows already installed 10). He, however, seems to be a clear or coherent solution. Can anyone help? Apparently the warranty on this unit (serial number, part number) expired on December 1, 2015, so even if I only bought it from the store on 2 February 2016, he is not covered - otherwise I would request a replacement, especially since the problem with the lid doesn't close does not correctly too...

    Thanks in advance, Martyn

    Hi - suddenly a similar probs with Tosh laptop Satellite... 2, w, s, and c keys do nothing. Upgrade to Windows 10 about six weeks ago... any ideas please? /

  • Select the data in a table and update in another table

    Dear experts,

    create the table TB_ENCRYPT

    (

    Identification number,

    Varchar2 (200) KEY

    );

    INSERT INTO TB_ENCRYPT VALUES(1,'HJUVHDUIFBSDGVU');

    SELECT * FROM TB_ENCRYPT;

    1 HJUVHDUIFBSDGVU

    create TABLE users)

    username, NUMBER of

    password VARCHAR2 (200)

    );

    Insert users

    values (1, 123 # "")

    Insert users

    values (2, 456 #')

    Select * from users;

    1 123 #.

    # 2 456

    I want to select the data KEY for table TB_ENCRYPT column and update in the column of tables for the respective key user password

    TB_ENCRYPT table contains only a single key value. Comparing this key, I want to update the old value of the key to the new value.

    For encryption and decryption I followed the java class method.no is worried about that.

    create or replace

    PACKAGE PCK_ENC AUTHID CURRENT_USER AS

    FUNCTION DECRYPT (VARCHAR arg0, arg1 VARCHAR) AS VARCHAR BACK LANGUAGE JAVA NAME 'Encrclass.decrypt (java.lang.String, java.lang.String) return java.lang.String ';

    FUNCTION ENCRYPT (VARCHAR arg0, arg1 VARCHAR) AS VARCHAR BACK LANGUAGE JAVA NAME 'Encrclass.encrypt (java.lang.String, java.lang.String) return java.lang.String ';

    END;

    SELECT PCK_ENC. ENCRYPT('1234','HJUVHDUIFBSDGVU') FROM DUAL;

    HERE,

    1234 - is the password of the users table column data

    HJUVHDUIFBSDGVU - represents the key of table TB_ENCRYPT column data.

    Comparing this key, I want to update the old value of the key to the new value.

    I tried with this method

    declare

    cursor c1 is

    Select the key

    of TB_ENCRYPT

    where id = 1

    update the id;

    Start

    for c1_rec looping c1

    update users

    password is PCK_ENC. Encrypt (Password, Key)

    the location being c1;

    commit;

    end loop;

    end;

    /

    Help, please

    You can use the MERGE statement.

    merge into users
    using tb_encrypt
       on (id = userid)
      when matched then
          update set password = PCK_ENC.ENCRYPT(password,key);
    

    And why you encrypt your password. This isn't a good idea. Just password hash.

  • Dell Inspiron 1501 laptop keyboard, it's that act as if the keys are pressed in 2 second intervals.

    Well, I mean about 6 months or if there is, we encountered a small problem with our laptop RAM and had it fixed by a professional. Since our RAM and CPU speed increased a little, however our keyboard seems to be on the fritz.

    I can't really explain or take screenshots of it in the law, but I will try my best. It seems that whenever I try to play a game, my keyboard gives to think I'm pressing '=' to an interval of 2 seconds. Recently, my sister tried to play "The Sims 2" on our PC and this problem appeared to cancel out all the actions that she wanted to make the game, as the selection of an object for the character to use, IE if she wanted to choose a furnace for a character to use, she would select it and have the small action menu pop up , but before she could select an action, the action menu would disappear. When I try to play a game, as "Half Life 2", I often change keys in order to adapt to my style of play, but when I try to change a key related, automatically "supports" the '=' button until I can manually select the key I want to bind to this control.

    I have never experienced this problem before we had our computer fixed and this problem seems to have no effect on typing programs such as Microsoft Word or Notepad or even this dialog, it doesn't seem to pop up in games so far, as far as I know, that he might happen while I'm typing this. It's just a minor annoyance, but it's a mystery that I can't solve. Any help or other questions that I can answer on the problem will be warmly welcomed. Thank you!

    Hello

    Looks like the other repair keyboard problem and it looks like not material. No doubt
    better to take this back to the place which sets memory.

    Control Panel - keyboard - look for a reset to the default values or other settings to fix the problem.

    I wonder if the sensitivity of the TouchPad could be a problem?

    Check with Support Dell and their Forums.

    Dell support
    http://support.Dell.com/

    Dell support drivers - product manual & warranty Info (left side) - and much more
    http://support.Dell.com/support/index.aspx?c=us&l=en&s=DHS

    Dell forums
    http://en.community.Dell.com/forums/
    I hope this helps.
    Rob - bicycle - Mark Twain said it is good.

  • Encrypt and decrypt using the key of the table

    Dear Experts,

    Here is my package to encrypt and decrypt with triples in oracle 11 g.

    In my package, I used encryption_key (3FECCDC7D348A85B096F0B43C4C6A38DBBD369DB37FEA435) according to this key we are encryption and decryption.

    My requirement is now, I don't want to spend the encryption_key in my code.we key stored in a table (key_details) and using the key column, we her encrypt and decrypt the data.

    -----------------------------------

    create the table key_details

    (

    Identification number,

    VARCHAR2 (48) key

    );

    insert into key_details values(1,'3FECCDC7D348A85B096F0B43C4C6A38DBBD369DB37FEA435');

    -------------------------------------

    CREATE or REPLACE PACKAGE encr_decr

    AS

    FUNCTION encrypt (p_plainText VARCHAR2) RETURN RAW DETERMINISTIC;

    FUNCTION decrypt (p_encryptedText RAW) RETURN VARCHAR2 DETERMINISTIC;

    END;

    /

    CREATE or REPLACE PACKAGE encr_decr BODY

    AS

    encryption_type PLS_INTEGER: = DBMS_CRYPTO. ENCRYPT_3DES

    + DBMS_CRYPTO. CHAIN_ECB

    + DBMS_CRYPTO. PAD_PKCS5;

    encryption_key RAW (48): = UTL_RAW.cast_to_raw ('3FECCDC7D348A85B096F0B43C4C6A38DBBD369DB37FEA435');

    FUNCTION encrypt (p_plainText VARCHAR2) RETURN RAW DETERMINISTIC

    IS

    encrypted_raw RAW (2000);

    BEGIN

    encrypted_raw: = DBMS_CRYPTO. ENCRYPT

    (

    SRC = > UTL_RAW. CAST_TO_RAW (p_plainText),

    Typ = > encryption_type,.

    key = > encryption_key

    );

    RETURN encrypted_raw;

    END encrypt;

    FUNCTION decrypt (p_encryptedText RAW) RETURN VARCHAR2 DETERMINISTIC

    IS

    decrypted_raw RAW (2000);

    BEGIN

    decrypted_raw: = DBMS_CRYPTO. DECRYPT

    (

    SRC = > p_encryptedText,

    Typ = > encryption_type,.

    key = > encryption_key

    );

    RETURN (UTL_RAW. CAST_TO_VARCHAR2 (decrypted_raw));

    END decrypt;

    END;

    /

    Help, please.

    create or replace package body encr_decr

    as

    encryption_type pls_integer: = dbms_crypto.encrypt_3des

    + dbms_crypto.chain_ecb

    + dbms_crypto.pad_pkcs5;

    gross encryption_key (48);

    --

    function encrypt (p_plaintext varchar2)

    gross return deterministic

    is

    Start

    Return dbms_crypto.encrypt (CBC-online utl_i18n.string_to_raw (p_plaintext)

    typ-online encryption_type

    key-online encryption_key

    );

    end encrypt;

    --

    function decrypt (gross p_encryptedtext) return varchar2 deterministic

    is

    Start

    Return utl_i18n.raw_to_char (dbms_crypto.decrypt (src-online p_encryptedtext

    typ-online encryption_type

    key-online encryption_key

    )

    );

    put an end to decrypt;

    Start

    Select the key in encryption_key

    of key_details

    where id = 1;

    end;

    /

  • In the form of table-update of rows based on the selection of the checkbox

    Hi all

    I have a tabular layout with line selector. I need to update manually checked columns, how would write a process audited records updated?

    Something like this:
    BEGIN     
         FOR i in 1..apex_application.g_f01.count LOOP
    
              IF apex_application.g_f01(i) is not null THEN
                   UPDATE TEST_USERS
                        set USER_ID = :P14_TO
                   WHERE rowid = :APEX$ROW_ID;
                   COMMIT;
              END IF;
         END LOOP;
    END;
    Thank you very much.

    You can refer to the line that you want to process through the value stored in the box.

    If you use apex_application.g_f01 (i) to make reference to the line and you want to update the row based on the ROWID in your request, your SQL query should have the box as follows:

    apex_item. CheckBox2 (1, rowid)

    Then your PLSQL process would be like this:

    BEGIN
         FOR i in 1..apex_application.g_f01.count LOOP
    
              IF apex_application.g_f01(i) is not null THEN
                   UPDATE TEST_USERS
                        set USER_ID = :P14_TO
                   WHERE rowid = APEX_APPLICATION.G_F01(i);
                   COMMIT;
              END IF;
         END LOOP;
    END;
    

    I hope this helps.

    Cheers, Pete

  • Select the top row of ADF Table default

    jdev 11.1.1. 6

    In my application, I have a fall towards the bass and based on the value, select from the drop-down list on the af: table is filled (using the drop-down list vcl property, I'm populating the VO based on which the table is).

    The table has "selectionListener" defined in a method at the bean so that every time a line is selected some operation.

    < af:table value = "#{bindings." RoleVO1.collectionModel}.

    var = "row" rows = "#{bindings." RoleVO1.rangeSize}"width ="500 ".

    "partialTriggers =": soc1: cb1: cb2.

    emptyText = "#{bindings." RoleVO1.viewable? "{'No data to display.': 'Access Denied.'}".

    fetchSize = "#{bindings." RoleVO1.rangeSize}.

    rowBandingInterval = '0 '.

    selectedRowKeys = ' #{bindings. " RoleVO1.collectionModel.selectedRow}.

    selectionListener = "#{CRoleARoleBean.roleTableSelection} '"

    rowSelection = "single" id = "t1".

    editingMode = "clickToEdit."

    Binding = "#{CRoleARoleBean.roleTable}" >

    I have here a certain way, I can make the top row of the selected table and trigger the selectionListener by programming the dropdown each time value is bud?

    Please notify

    by selecting the default line can be obtained by adding after the vcl in drop-down list:

    this.roleTable.setRowIndex (1);

    RowKeySet ch = this.roleTable.getSelectedRowKeys ();

    PS. Clear();

    PS. Add (this.roleTable.getRowKey ());

    AdfFacesContext.getCurrentInstance () .addPartialTarget (this.roleTable);

    Make sure the displayRow selected = is defined in the table property

  • Automatically select the correct check box based on choices made in the previous section?

    With the help of LiveCycle to create a form that contains a table. This table has 3 columns with 15 boxes in each column.

    Here are these 15 rows 3 more boxes that have calculated values. In each row of the table one of the checkboxes can be active at a time.

    Based on the majority of choices in a column of some, the calculated corresponding checkbox must be verified. (If most of the choices are made in column 1, then the 1st calculated box must be marked, etc...)

    The sentence that I am writing the JavaScript code that selects the checkbox correctly calculated. Currently, I'm just trying to understand it with only 3 first lines and I can reproduce the template after.

    Table e.g.: ("BOLD" is calculated)

    CheckBox20CheckBox35CheckBox50
    CheckBox21CheckBox36CheckBox51
    CheckBox22CheckBox37CheckBox52
    [CheckBox66][CheckBox67]

    [CheckBox68]

    Here's the code I came up with that day, but it does not just anyone, although when I used it it worked just to 2 columns. (just added the part about the third column in the instructions 'or')

    (In the script for the calculation of box 66)

    //larger values than other columns
    if ((Row1.CheckBox20.rawValue == "") + (Row2.CheckBox21.rawValue == "") + (Row3.CheckBox22.rawValue == "") > (Row1.CheckBox35.rawValue == "") + (Row2.CheckBox36.rawValue == "") + (Row3.CheckBox37.rawValue == "") || (Row1.CheckBox50.rawValue == "") + (Row2.CheckBox51.rawValue == "") + (Row3.CheckBox52.rawValue == ""))
     {this.rawValue = "0";}
    
    //smaller values than other columns
    if ((Row1.CheckBox35.rawValue == "") + (Row2.CheckBox36.rawValue == "") + (Row3.CheckBox37.rawValue == "") || (Row1.CheckBox50.rawValue == "") + (Row2.CheckBox51.rawValue == "") + (Row3.CheckBox52.rawValue == "") > (Row1.CheckBox20.rawValue == "") + (Row2.CheckBox21.rawValue == "") + (Row3.CheckBox22.rawValue == ""))
     {this.rawValue = "1";}
    

    I'm new to JavaScript for all advice is appreciated.

    Looking at the conditions, it seems you are trying to say "If column 1 column 2 or column 3, then do something." JavaScript cannot read conditions like that. It's playback "if (column 1 column 2) GOLD (column 3), ' and he doesn't know what to do with this issue of column 3, except if it is 0 or 1.

    Here is an example of use of only two lines and three columns. The rawValues are 0 and 1 for each check box. I have it set so that if column 1 has several checkboxes, then Col1 gets checked. Similarly, the col2 or 3 boxes will be checked if their columns are the most populated. I don't get the opportunity to have several boxes marked if there are two columns that have the same number of boxes checked. (You can do this by just changing > to > = in the conditions.)

  • By selecting the last row of the table

    I'm trying to select the last row in a table. The tables will have a different number of lines, so I can't select based on a line number. I tried to use the location options, but get an error that "the object is not a function". Not sure what the problem is.

    table = app.selection[0];
    if (table.hasOwnProperty("baseline")) table = table.parent;
    if (table instanceof Cell) table = table.parent;
    if (table instanceof Column) table = table.parent;
    if (table instanceof Row) table = table.parent;
    if (table instanceof Table)
    
    {
                table.rows(LocationOptions.AT_END).cells.texts.everyItem().fontStyle = "regular";
     }
    

    You can use the placement options for this?

    Hello

    table. Rows being a collection of object using the index-[1] is a proper way

    but cells.texts generates an error. Change it to:

    table.rows[-1].cells.everyItem().texts.everyItem().appliedCharacterStyle = "myriad regular";
    

    Jarek

  • Select the line of contour based on static text

    Hello

    Thank you much in advance.

    As I'm fairly new to AppleScript, I don't know what is and what is not possible. My goal is to have a single script that works for 7 of our branches and about 1,500 people. The idea for the script is:

    1. ask the user some basic questions (like "which office are you?" and "What is your code print?" - already scripted.)

    2 something here to select the appropriate section of the code required for these specific functions. In other words, if user pics office 1 go to any section of the code that corresponds to the office 1 if 2 go 2, etc. - not scripted, I'm used to something like goto, but if I understand well there is no such thing with ACE

    3. based on the information in the point 1, if possible, download a file from the internet (a package) and install it. I guess I should wait or pop to draw their attention to the fact that they would need their password and wait they ended as a dialog box. I know that the password is not scriptable. - not scripted

    4. a procedure (for each location but very similar) script:

    4.1 find if printers have been installed (based on the content of the Printers & Scanners window and printer names). - ongoing

    4.1.1. If so, select and remove.

    4.1.2 if not, continue

    4.2 install printers for this office. - scripted.

    4.3. implement their code printing with a couple of presets - scripted

    Where I am stuck currently is:

    1 choice of the line of the scroll printers area contour & Scanners based on the name of the printer. I try this, but it does not work (for some reason any CRUDE HTML does not work):

    Tell application "System events" tell process select 'System Preferences' (first line of end of plan 1 zone 1 scroll the window 1, including the value of static text 2 is "SAvin_372BC" tell end tell

    Accessibility Inspector is telling me this:

    AXApplication > AXWindow:AXStandardWindow > AXScrollArea > AXOutline > AXRow:AXOutlineRo w > AXCell > AXStaticText for the text where the Savin_372BC is displayed. I found this and tried to do something similar to script, but obviously I did not. As I do not know how many printers user will have I need for AS through, find those that we install and remove them if they are present and move along, otherwise - move along.

    2. how script logic? As I mentioned previously, I'm used to goto, so it would be to ignore whatever the section, I need to continue from. What would be the AS version for goto?

    3. using the script and without install anything that anyone else who isn't Apple, how do I download a pkg in / downloads? CURL?

    4. I'm not there yet, but no matter what magic trick as waiting for an entry for the Mac password?

    Thanks a lot again!

    I'm used to something like goto, but if I understand well there is no such thing with ACE

    The man.  GoTo went in disgrace for 40 years!  No modern language has goto. GoTo lead unrestricted branching which resulted in convoluted code.  A fluidity in the code is desirable.

    From this page:

    http://computers.tutsplus.com/tutorials/if-and-if-else-AppleScript-conditional-s statements - mac-45590

    ------------------------------------- AppleScript

    Learn AppleScript: The comprehensive Guide to Scripting and automation on Mac OS X, the book of the third edition

    AppleScript Language Guide pdf Download pdf file

    Intro to applescript with the sending of an email
    http://Mac.AppStorm.NET/how-to/AppleScript/the-ultimate-beginners-guide-to-Apple script.

  • Select the Tunnel-Group based on OS devices

    Hello

    having an ASA5512x is possible to have anyconnect-dial-in-PC-users asking their IDs AND also a one-time-password

    Whereas smartphone users only need to provide their username and a password without the need to manually select the profile?

    I've set up two groups of tunnel:

    (1) requires an LDAP server for authentication

    (2) is in contact with a RADIUS server running the software One Time Password.

    Is it possible to have the asa affect smartphone users (based on their OS) that it automatically uses the first profile (which has limited access to the resources of the intranet) and Anyconnect-PC-users pinned to the second category of tunnel? Dynamic access policies seem to be able to differentiate only ' in' a tunnel-group.

    Thank you very much!

    Kind regards

    David

    I never tried this way, but if it does not (as I suspect) there is a solution:

    1. Point your customers on the two different groups of tunnel with the help of tunnel-group-URL.
    2. Later in the DAP impose that the customer does not use the wrong tunnel-group.
  • How to give users the ability to select the rate based on HSP_Begin, HSP_Average or HSP_ending

    Hello

    We wanted to give users the ability to select the rate based on HSP_Begin, HSP_Average or HSP_ending.  How you would achieve this?

    I have some ideas:

    (1) a less optimal solution is to create a user variable called FX_Beg_Ave_End, and then run a HBR script to perform the conversion of FX before completing the form.  The HBR will prompt the user to enter "HSP_Begin, HSP_Average or HSP_ending.  He's going to calc and display the converted data in the form based on the user input.  It's embarrassing because users must type in 'HSP_Begin, HSP_Average or HSP_ending' to all forms.  It is also better to pull data directly from one of the members: 'HSP_Begin, HSP_Average or HSP_ending'.

    (2) a better alternative is to put the POV of the form points to the variable user FX_Beg_Ave_End.  When the form appears, it will draw the name of the FX_Beg_Ave_End member variable and display the data of the Member (for example 'HSP_Begin, HSP_Average or HSP_ending') stored in FX_Beg_Ave_End.

    Thanks for your ideas.

    Hello

    In fact for your option, so you could make a selection of members would not have users typing the name.

  • Select the first or last row of sql Command

    Hello

    I am trying to get the fist or the last line of output from sql below

    SQL> set head off;
    SQL> select  r.actual_start_date,r.phase_code,r.status_code,r.actual_completion_date from
      2      apps.fnd_concurrent_programs_vl p, apps.fnd_concurrent_requests r
       where p.concurrent_program_id = r.concurrent_program_id
      3    4      and p.application_id = r.program_application_id
      5      and p.user_concurrent_program_name like 'Purge Concurrent Request and/or Manager Data'
      6  and  r.actual_start_date >= sysdate-7
    --and rownum<1
      7    8  --order by r.requested_start_date
      9  ORDER BY r.actual_completion_date DESC;
    
    
    29-DEC-13          C C 29-DEC-13
    28-DEC-13          C C 28-DEC-13
    27-DEC-13          C C 27-DEC-13
    26-DEC-13          C C 26-DEC-13
    25-DEC-13          C C 25-DEC-13
    24-DEC-13          C C 24-DEC-13
    23-DEC-13          C C 23-DEC-13
    
    
    7 rows selected.
    
    
    SQL> select  r.actual_start_date,r.phase_code,r.status_code,r.actual_completion_date from
      2      apps.fnd_concurrent_programs_vl p, apps.fnd_concurrent_requests r
       where p.concurrent_program_id = r.concurrent_program_id
      3    4      and p.application_id = r.program_application_id
      5      and p.user_concurrent_program_name like 'Purge Concurrent Request and/or Manager Data'
      6  and  r.actual_start_date >= sysdate-7
      7  and rownum<2
      8  --order by r.requested_start_date
      9  ORDER BY r.actual_completion_date DESC;
    
    
    
    27-DEC-13          C C 27-DEC-13
    
    
    
    
    
    
    SQL> select  r.actual_start_date,r.phase_code,r.status_code,r.actual_completion_date from
      2      apps.fnd_concurrent_programs_vl p, apps.fnd_concurrent_requests r
       where p.concurrent_program_id = r.concurrent_program_id
      3    4      and p.application_id = r.program_application_id
      5      and p.user_concurrent_program_name like 'Purge Concurrent Request and/or Manager Data'
      6  and  r.actual_start_date >= sysdate-7
      7  and rownum<1
      8  --order by r.requested_start_date
      9  ORDER BY r.actual_completion_date DESC;
    
    
    no rows selected
    
    
    SQL>
    
    

    I want to get the last run of the program which is the first line of the top of the output of sql. (which is December 29, 13, first row on top of the exit)

    But if I use the condition as ' where rownum < 1, its not giving any output, if I use where rownum < 2, if you do not have out. "

    Grateful if someone can help.

    -Thank you

    Vijay...

    Hi Vijay,

    The following should work...

    ROWNUM< 1="" will="" not="" retrieve="" any="" rows="" as="" rownum="" values="" start="" with="" 1.="" to="" get="" the="" desired="" result="" you="" have="" to="" build="" the="" result="" set,="" order="" it="" and="" then="" select="" the="" desired="">

    SELECT *.

    Of

    (SELECT r.actual_start_date,

    r.phase_code,

    r.status_code,

    r.actual_completion_date

    Apps.fnd_concurrent_programs_vl p,

    Apps.FND_CONCURRENT_REQUESTS r

    WHERE p.concurrent_program_id = r.concurrent_program_id

    AND p.application_id = r.program_application_id

    AND p.user_concurrent_program_name LIKE 'Serve concurrent demand and/or Manager Data'

    AND r.actual_start_date > = sysdate-7

    -Order of r.requested_start_date

    ORDER BY r.actual_completion_date DESC

    )

    WHERE rownum< 2="">

    I hope this helps.

    VR,

    Sudhakar

Maybe you are looking for