How to select record Datestamp Maximum

It's data.

The number Type Datestamp
IM10134 001 was 10413 Open 2010-07-19 07:51:43.000
IM10134 001 has 10424 Status Change-2010-08-02 09:45:27.000
IM10134 001 A 10425 provider external assignment 2010-08-02 09:45:27.000
IM10134 001 A 10426 update 2010-08-02 09:47:49.000

I want results for the following fields. So the result is

The number Type Datestamp
IM10134 001 A 10426 update 2010-08-02 09:47:49.000

How to select this folder only

Kindly help me.

You can try:

SELECT x.number,y.thenumber,y.type,x.date_stamp
FROM   (SELECT number,MAX(datestamp) date_stamp FROM table_name GROUP BY number) x,
table_name y
WHERE x.number = y.number
AND x.date_stamp = y.datestamp;
/

Tags: Database

Similar Questions

  • How to select records in the duplicate and two copies lines no rows

    Hello

    I'm working on Oracle with the following details
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64 bit Production
    With partitioning, OLAP and Data Mining options

    I need help to choose one of the duplicate records and a few duplicate not based on condition. I wrote the script that only gives me one of the record list duplicate, but I'm confused how select duplicate duplicates.

    My condition is to select all records where TARGET TABLE AND TARGET_COLUMN IS NOT NULL. I need to select unique records of this this condition based on these attributes only Anwar. _

    _ From the SOURCE

    TARGET_TABLE TARGET_COLUMN SRC_COLUMN
    -----
    --------------------
    -----
    SRC_EXTERNAL SUBJECT_AREA SUBJECT_AREA
    FISCAL_YEAR FISCAL_YEAR SRC_EXTERNAL
    PARTY_ID_ORG PARTY_ALT_ID PARTY_ID
    PARTY_ID_NEW PARTY_ALT_ID PARTY_ID
    ESTABLISHMENT_NBR_ORG W2_EMPLOYER ESTABLISHMENT_NBR
    ESTABLISHMENT_NBR_NEW W2_EMPLOYER ESTABLISHMENT_NBR
    EMPLOYMENT_CODE_ORG W2_EMPLOYER EMPLOYMENT_CODE
    EMPLOYMENT_CODE_NEW W2_EMPLOYER EMPLOYMENT_CODE
    SICK_PAY_IND_ORG W2_EMPLOYER SICK_PAY_IND
    SICK_PAY_IND_NEW W2_EMPLOYER SICK_PAY_IND
    AGENT_IND_CODE
    AGENT_FEIN
    EMPLOYER_NAME
    EMPLOYER_ADDRESS
    CLIENT_ADDRESS
    CITY
    STATE
    ZIP

    _ REQUIRED TARGET

    TARGET_TABLE TARGET_COLUMN SRC_COLUMN

    -----
    --------------------
    -----
    SICK_PAY_IND_NEW W2_EMPLOYER SICK_PAY_IND
    EMPLOYMENT_CODE_NEW W2_EMPLOYER EMPLOYMENT_CODE
    ESTABLISHMENT_NBR_NEW W2_EMPLOYER ESTABLISHMENT_NBR
    PARTY_ID_NEW PARTY_ALT_ID PARTY_ID
    SRC_EXTERNAL SUBJECT_AREA SUBJECT_AREA
    FISCAL_YEAR FISCAL_YEAR SRC_EXTERNAL

    MY QUERY_ +.


    SELECT NOMFICHIER_SRC, TARGET_TABLE, SRC_COLUMN, TARGET_COLUMN
    OF ITS_STAGE. STG_EDW_METADATA X
    WHERE TARGET_TABLE IS NOT NULL AND TARGET_COLUMN IS NOT NULL
    AND ROWID & gt; (SELECT MIN (ROWID)
    OF ITS_STAGE. STG_EDW_METADATA Y
    WHERE TARGET_TABLE IS NOT NULL AND TARGET_COLUMN IS NOT NULL
    AND Y.TARGET_TABLE = X.TARGET_TABLE
    AND Y.TARGET_COLUMN = X.TARGET_COLUMN)



    MY RESULTS+ _
    TARGET_TABLE TARGET_COLUMN SRC_COLUMN

    -----
    --------------------
    -----
    SICK_PAY_IND_NEW W2_EMPLOYER SICK_PAY_IND
    EMPLOYMENT_CODE_NEW W2_EMPLOYER EMPLOYMENT_CODE
    ESTABLISHMENT_NBR_NEW W2_EMPLOYER ESTABLISHMENT_NBR
    PARTY_ID_NEW PARTY_ALT_ID PARTY_ID

    Can some Oracle expert please help me solve this problem.

    Thanks in advance

    Rajesh

    Published by: user532468 on 15 Sep, 2008 14:32

    With the help of

    AND ROWID * > * (SELECT MIN (ROWID)

    you select duplicates. Just change of

    AND ROWID * = * (SELECT MIN (ROWID)

    This will select everyring but duplicates. However, it is not effective. All you need is:

    SELECT SRC_FILENAME,SRC_COLUMN,TARGET_TABLE, TARGET_COLUMN
    FROM (SELECT DISTINCT * FROM  ITS_STAGE.STG_EDW_METADATA X
    WHERE TARGET_TABLE IS NOT NULL AND TARGET_COLUMN IS NOT NULL)
    

    SY.

  • How to select Records databases on a group

    Have a nice day together.

    I have two tables and their records are inserted as below.

    1. CREATE THE INVOICE_HEADER TABLE (INVOICE_NUMBER NUMBER (6), VAT_INDICATOR CHAR (1));

    insert into invoice_header values('000001','E');

    2. CREATE THE INVOICE_SELECTOR TABLE (INVOICE_NUMBER NUMBER (6), INVICE_LINE VARCHAR2 (3), APPROVED_INDICATOR CHAR (1));

    insert into invoice_selector values('000001','A00','Y');

    insert into invoice_selector values('000001','B00','N');

    Now, I want to show the invoice_number '000001' only if the approved flag is set to 'Y' for the two invoice lines.  If one of the two has the value "n" while the header should not be recovered.


    I tried this using pl/sql. But do I know what a concept I'd be familiar in SQL. I am pleased that those who are interested in helping.



    Thank you

    Mohammed


    Set serveroutput on;

    declare

    flag_set VARCHAR2 (1);

    Start

    FOR (IN) logi

    Select inh.invoice_number in the inh invoice_header join invoice_selector ivs

    We inh.invoice_number = ivs.invoice_number)

    loop

    for log base 2 in (select INVICE_LINE from the invoice_selector where invoice_number = logi.invoice_number)

    loop

    If (log2.invice_line = 'Y') then

    flag_set: = 'Y ';

    -dbms_output.put_line ("No Found Bill" | logi.invoice_number);

    on the other

    -dbms_output.put_line ("Found Bill" | logi.invoice_number);

    flag_set: = 'n';

    end if;

    end loop;

    end loop;

    If flag_set = "Y" then

    dbms_output.put_line ('valid invoice");

    on the other

    dbms_output.put_line ('invalid invoice");

    end if;

    end;


    Select * from invoice_header:

    where there is not (select null to s invoice_selector

    where s.invoice_number = h.invoice_number

    and (s.approved_indicator! = 'Y' or s.approved_indicator is null))

  • How to select records from an object of type

    CREATE TABLE BOOKING_ITERATION
    (
      SK_BOOKING_ID               NUMBER(20)        NOT NULL,
      BOOKING_TRANS_DATE          DATE              NOT NULL,
      LAST_CALCULATED_DATE        DATE,
      MAX_CALCULATED_TOLERANCE    NUMBER(2),
      CALCULATION_SUCCESSFUL_IND  VARCHAR2(1 BYTE),
      BOOKING_CALC                BOOKING_CALC_ATTRIBUTES_T
    )
    
    
    CREATE OR REPLACE /* Formatted on 24/06/2009 14:57:50 (QP5 v5.115.810.9015) */
    TYPE booking_calc_attributes_t AS OBJECT(
      booking_rec                      top_bkg_basic_rec_t,
    
      accom_costs_initialsed           VARCHAR2(1),
      flight_costs_initialsed          VARCHAR2(1),
      fin_details_initialsed           VARCHAR2(1),
      business_transaction_id          INTEGER,
      accom_unit_service_id            INTEGER,
      product_id                       INTEGER,
      subproduct_id                    INTEGER,
      subproduct_code                  VARCHAR2(3)
    )
    now my requirement is to select values in the table BOOKING_ITERATION where product_id = 101
    can you please advise me on how to do it.

    Concerning

    Nested object type attributes can be considered with the notation by simple point. However, this is slightly obscured by the fact that a table alias is required for name resolution. I hope that this example will help...

    SELECT bi.sk_booking_id
    FROM   booking_iteration bi
    WHERE  bi.booking_calc.product_id = 101;
    
  • How to select a value to a maximum value of another column in the same line?

    pVersion pdate pcount
    11 1/6 / 2011 1
    06/11/2011 0, 25
    11 1/6 / 2011 24

    How to select for a maximum pcount pversion, in this case count max is 25 and version will be 0?

    tcode wrote:
    pVersion pdate pcount
    11 1/6 / 2011 1
    06/11/2011 0, 25
    11 1/6 / 2011 24

    How to select for a maximum pcount pversion, in this case count max is 25 and version will be 0?

    WHERE PCOUNT = (SELECT MAX (PCOUNT) FROM TABLE1)

  • How to select valid dates only

    If I have a table with a column varchar2 as below, how to select records that contain only valid dates? As there is no 2010-04-31, so I need only to bring on 2010-04-30, which is a valid date.

    Select '2010-04-30'd from the double. "
    Union of all the
    Select '2010-04-31'd from the double. "

    I'm on Oracle 10.2

    Published by: Rinne on April 23, 2010 11:15

    Hello

    Tubby wrote:
    An option using SQL only, although something like that, I tend to go with the solution of francs to a user defined function. Because if you store dates as strings, you're likely to have more than just 1 kind of "bad" data in the string.

    If you try a pure-SQL solution, make sure that it does not raise an error when d is an absolute stupidity (for example, when d = "TOTAL GARBAGE").
    Do something like this:

    WHERE   CASE
              WHEN  d     IS NULL
              THEN  'Missing'
              WHEN  TRANSLATE ( d
                              , '012345678'
                        , '999999999'
                        ) != '9999-99-99'
              THEN  'Invalid format or non-numeric'
              WHEN  SUBSTR (d, 1, 4)     = '0000'     -- or test for implausible years, e.g. "< '1900'"
              THEN  'Invalid year'
              WHEN  SUBSTR (d, 6, 2)     NOT BETWEEN  '01'
                                                AND          '12'
              THEN  'Invalid month'
              WHEN  SUBSTR (d, 9, 2)     NOT BETWEEN  '01'
                                                AND          TO_CHAR ( LAST_DAY ( TO_DATE ( SUBSTR (d, 1, 7)     -- no need for "|| '01'"
                                                                          , 'YYYY-MM'
                                                        )
                                                 )
                                            , 'DD'
                                            )
              THEN  'Invalid day'
              WHEN  d     BETWEEN '1582-10-05'     -- If necessary
                         AND     '1582-10-14'
              THEN  'Julian-Gregorian calendar change'
              ELSE  'Okay'
         END     = 'Okay'
    

    In my opinion, it intercepts all possible errors in common dates of the time.

    Published by: Frank Kulash, April 23, 2010 12:57

  • How to select a record in one table to manipulate data in a database?

    Hello community,

    Using 32-bit Labview 2015.

    I created a user interface that runs a query and retrieves my table from a sql database.

    I want to be able to manage only one record at a time by selecting the record in my table and then manipulate the data according to the needs.

    Whenever the user runs a query, I want as the first record in the table to be selected / highlighted.

    I want an indicator that is currently active.

    Then a click of a button, to be able to scroll the actively selected record.

    Once I have the selected record, I want a way to write a query to edit or delete the record.

    Is attached a photo of my query to select all of my table and connect data in my table (results).

    Attached a photo of my painting showing the timeline of my sql database.

    What is the best way to go on a record selection in a table and the modification of data with a query?

    Any help would be greatly appreciated.

    Thank you

    I guess that's not a table, but multi-column listbox.

    Right click, select--> highlight whole line selection Mode

    The value of the multicolumn listbox is the row index - you can write a local variable to highlight the line, the event structure to handle the user clicking on, etc.

    If you enable the property editable ListBox cells, you can allow users to edit the items of the listbox.

    If you want to get the data in row, you hint REF table and work with the array of strings in row - convert it to cluster, etc..

    I don't know, what type of data, it is, how you structure the database looks like, I don't even know if you use the wrapper to work with the database, I can't write queries for you.

    Something like Update Tablica Set Serial = '5' where ID = '22';

  • How to select the values for each check box in a group of records

    Hello

    I have a requirement in form 10g. In this form there are 10 records are display each record has a checkbox is there if I click on the check box save number one and number three and make some changes in the text field (field adjustment is the number data type) and then finally, I want to see the total a total amount called field.

    In this, my question is how to select specific to a group of records records? and finally these selected records are inserted in a table.
    Because I am not able to read these records at a time.
    Is there any table to define a record group to fetch each of them individually for example Rec [1] Rec [2]... like this if yes please suggest me the steps how to do this.

    Thanks in advance
    Prasanna

    Published by: user10315107 on December 17, 2008 23:44

    OK, so you want to shoe the total amount in the form itself (I guess that somewhere under the dashboard lines?).

    You can do this easily using formulat elements:

    1 create a new item in your block where the field amount is places, set "section of the database" on the 'No', 'calculation mode' to the 'formula' and the 'formula' himself to something like:

    CASE WHEN :BLOCK.CHECKBOXITEM=CHECKVALUE THEN :BLOCK.AMOUNT+:BLOCK.ADJUSTMENT ELSE 0 END;
    

    This formula returns 0 if the checkboxitem is not checked, otherwise the sum of amount and adjustment (of course you can adjust the names of elements and the value for 'Checked')
    2. place the element in the layout, if you wish.
    3. set the property "Query all Records" to "true" for your block elements, this is necessary for the calculation to work
    3 create a control block to keep summary article in a, "Single Document" set to 'True '.
    4. place a new element in this control block, set 'Calcuation mode' to 'Summary', 'Summary block' to your block elements, 'Summary point' in newly created formula section in the block elements
    and function of synthesis for the "sum".
    5. place the element in the layout

    She's.

  • How can I record audio programs that run through Windows 7 on the sound recorder? Where is the master volume.

    How to record audio programs in windows 7? -in previous versions of windows, I could use the main volume control to select "wave" and that way save audio playing on other programs playing through windows and using windows as a simple sampling devicem - I have a relatek 11 hd audio device/card's directx - in audio devices ControlPanel / / / / material/sound/manage / I see only selection of recording for the microphone or line - how can - record sound through windows 7 - can I buy a cable and put it in the headphone and microphone - I'm trying to address the problem in a way that is now not in windows - I want to play things and recording in a small way - could you provide an answer on how audio intgrates of hardware and software with windows - I can't believe really wanting I could do on the previous windows versions - please help

    Start - All Programs - Accessories - Sound Recorder will launch the utility. You can easily find it by running aid and entering "sound recording."

    Right click the speaker icon in the system tray, select recording devices and set the desired default entry.

  • How can I get the maximum salary of the first ascending

    Hello

    How can I get the maximum salary of the first in ascending order.
    I need the sql query.

    want my output:

    Emp_name salary
    A 5000
    SS 100
    300 AA
    DD 700
    WW 2000



    Thank you
    Walid.

    Here is an example:

    SQL> with mytable as
      2  ( select 'aa' as col1,  300 col2 from dual union all
      3    select 'ss' as col1,  100 col2 from dual union all
      4    select 'a'  as col1, 5000 col2 from dual union all
      5    select 'dd' as col1,  700 col2 from dual union all
      6    select 'ww' as col1, 2000 col2 from dual )
      7  select col1, col2
      8  from   mytable
      9  order by decode(row_number() over (order by col2 desc),1,0,1),col2;
    
    CO       COL2
    -- ----------
    a        5000
    ss        100
    aa        300
    dd        700
    ww       2000
    
    SQL>
    

    Nicolas.

  • How to use record group to insert data into the hierarchy tree?

    Hello

    I had a hierarchical tree in my block and I want to use the record group to display
    in the hierarchy tree, call david_tree. He did work for the code I try below
    and I think it might be that the create_group_form_query was wrong? or miss an order?


    DECLARE
    htree;
    rg_data RECORDGROUP;
    v_ignore NUMBER;
    BEGIN
    htree: = Find_Item ('tree_block.david_tree');

    rg_data: = CREATE_GROUP_FROM_QUERY ('rg_bank',
    "select name, short_name".
    || "from css_banks");

    -Fill the record with data.

    v_ignore: = POPULATE_GROUP (rg_data);

    -Transfer the data from the record group to the hierarchical
    -tree and bring it to display.

    FTREE. SET_TREE_PROPERTY (htree, FTREE. (RECORD_GROUP, rg_data);

    END;


    Thank you


    David

    David,
    You get an error with your code? Looks like you took your example code help Forms. I don't really see a problem with the code, but the forms example gives an example of how create the record group used by the HTree so the Receiver General may be the cause of the problem. When I used the HTree, I used the FTREE. Procedure ADD_TREE_DATA to fill the tree. When I started working with HTree I created a wrapper package to simplify the process. You can watch how I work with the HTree in a demo that I published called: forms and how to: create a shape of the HIERARCHICAL tree.

    Hope this helps,
    Craig B-)

    If someone useful or appropriate, please mark accordingly.

  • Printing from multiple records data for a selected record

    Hello...

    I have a multi disk block. My client wants to print a report based on the
    record it selects / clicks.

    For example, if my employee block has 20 records and my customers click on 7th recording then
    Click the print than the specific details that should be included in the report.
    I want to know how to use the form for reports of this situation.

    Timely help is needed here...

    Thanks in advance...

    Hello

    The suggestion provided by Kame requires the user to enter the value of the DOC. In your case, you want the State to print according to the selected record by the user (which happens during execution).

    In order to achieve, you must write a trigger pre-requete and assign the empno value to a global variable and then pass this global as a parameter empno variable when we click on the button to run the report.

    Pré-requête

    : GLOBAL .empno: =: BLOCK. COLUMN;

    It will be useful.

  • How to select all of the people who are not in any team?

    Hello

    I have a nice SQL expression that gives me accordingly all the "AGENTS" (people) working in a TEAM (a team)

    Select one. "" AGENT_ID. "
    a."NAME" | ' ' || a.' first NAME' 'Name',
    c.libelle 'team ', he said.
    a."DATE_EMBAUCHE" "Hire Date"
    a."DATE_DEBAUCHE" «Date debauchery. "
    of the OBSERVATORY. "" AGENT. "
    b Observatoire.equipe_agents,
    c Observatoire.Equipe
    where a.agent_id = b.agent_id
    and b.equipe_id = c.equipe_id
    order by name

    Now, how to select all the agents who do NOT work in any 'TEAM' (team)?

    I tried but could not succeed!

    Thank you for your help.

    Christian

    Dave solutions use an outer join ((+) in the joints), which should bring back all the records of the agent, even if they do not exist in the equipe_agents table.

    Another approach would be to use a statement NOT EXISTS or NOT IN, for example

    SELECT   *
    FROM     agents a
    WHERE    NOT EXISTS (  SELECT   1
                           FROM     equipe_agents ea
                           WHERE    ea.agent_id = a.agent_id
                         )
    
  • How to select entire groups or to multiple recipients in MAIL, rather than one at a time?

    How to select entire groups or to multiple recipients in MAIL, rather than one at a time?

    One way is to use the app to create a group with the intended recipients. Then when composing the email just type the group name in the To: field.

  • How to select and move more than one bookmark at a time? Shift + click selects multiple items that are next to each other in a list, because the element

    How to select and move more than one bookmark at a time?
    Shift + click selects multiple items that are next to each other in a list, because the items open in firefox before that happens.

    Glad it worked for you. Thanks for posting back.

Maybe you are looking for