get the latest dates

Hello
I have a simple question... .i do not know why I m brain dead today...

I m trying to get the date limit for the id of each

with test_data as(
select '001'id, 'xyz'name, '1/1/2009'start_date from dual union all
select '001',  'abc', '1/2/2099' from dual union all
select '001',  'def', '1/3/2009' from dual union all
select '001',  'ghi', '1/4/2009' from dual union all
select '001',  'jkl', '1/5/2009' from dual 
)

The output i m looking for just one record with latest date
  with result as 
  (
     select '001',  'jkl', '1/5/2009' from dual  
   )

i tried this 

 select id,name, greatest(start_date) from test_data
  group by id,name,start_date 
  
It gives me output ...which i m not lookg for 

  with t as 
  (
     select '001',  'abc', '1/3/2009' from dual union all 
     select '001',  'ghi', '1/4/2009' from dual union all
     select '001',  'jkl', '1/5/2009' from dual 
   )select * from t
   
I was wondering if we have any function in oracle PL/SQL to do this kind of things

Any suggestion is greatly appreciated! Thanks much sio!

Published by: user642297 on March 12, 2010 12:21
SQL> with test_data as(
  2  select '001'id, 'xyz'name, '1/1/2009'start_date from dual union all
  3  select '001',  'abc', '1/2/2099' from dual union all
  4  select '001',  'def', '1/3/2009' from dual union all
  5  select '001',  'ghi', '1/4/2009' from dual union all
  6  select '001',  'jkl', '1/5/2009' from dual union all
  7  select '002',  'ghi', '1/4/2009' from dual
  8  )
  9  select id, max(start_date), max(name) keep (dense_rank first order by start_date desc)
 10  from test_data
 11  group by id;

ID  MAX(STAR MAX
--- -------- ---
001 1/5/2009 jkl
002 1/4/2009 ghi

Max
http://oracleitalia.WordPress.com

Tags: Database

Similar Questions

  • Get the latest data of Variable shared before disconnecting from the network

    Hello.

    I use Shared - published network variables for my communication between two PC's. Each LV software will pass the data to another.

    Sometimes the wireless connection to become really bad and the network connection stops.

    I want to get the latest data. Currently my VI will show the value '0' on the variable shared data once the connection is cut.

    I tried using shift, but she registers the same results.

    Can someone show me how I can stay past data when the network connection is disconnected.

    Thank you very much.

    Kind regards

    Hello Fan, Ravens

    It works! Thank you very much.

    Kind regards

  • How to always get the latest data in ADF rowSetIterator

    Hello guys

    I have a method that I run on pageLoad to check the data in the database. Here I use rowsetiterator. I get the data fine but if I insert a new row and load the page again once, he did not get the newly inserted line and watch the old line set.

    I tried to run the query on the iterator, but did not work. This is the Council of Europe that I use. Can you get it someone please let me know if I'm missing something?

    DCIteratorBinding MyDCIter is getBindings () .get ("MyView1Iterator") (DCIteratorBinding);.

    MyDCIter . executeQuery();

    RowSetIterator rsi = MyDCIter . getRowSetIterator().

    RSI. Reset();

    I guess I found the problem.

    He has been to the while loop. When I use while (rsi.hasNext ()) is the first line to jump and iteration of second line.

    So I changed to loop, as for (int i = 0; i)

  • Get the latest date DML for all tables

    Hi gurus,

    Version - ORacle 11i

    I need to get a list of the tables that was not 'DML used' for a long time (updates/Inserts / (and selects too if available)). I searched for this in the forum and found 3 methods I used

    1 insert/update dtm
    ----------------------------------
      SELECT DISTINCT table_name, T.COLUMN_NAME
        FROM all_tab_cols t
       WHERE UPPER (T.COLUMN_NAME) LIKE 'UPD%'
             OR    UPPER (T.COLUMN_NAME) LIKE 'INSERT%'
               AND T.OWNER = 'STG'
               AND T.DATA_TYPE IN ('TIMESTAMP', 'DATE')
    ORDER BY column_name
    
    Issue- Not all the tables have inaert/upd dtm
    2 all_tab_modifications
    -------------------------------------
      SELECT table_Name, timestamp
        FROM all_tab_modifications t
       WHERE T.TABLE_OWNER = 'STG'
    ORDER BY timestamp ASC
    
    Issue - Not all tables are monitored
    3 ORA_ROWSCN
    ------------------------------------------
    select MAX(ORA_ROWSCN), SCN_TO_TIMESTAMP(MAX(ORA_ROWSCN)) from stg.XXXXXX
    
    Issue- This throws error MAX(ORA_ROWSCN) is not a valid input . ie for really old tables this throws error.
    How do I get there?

    Thank you
    S

    957793 wrote:
    Thank you peter.

    But one thing I noticed, sometimes at the time where I start an analysis table calculates statistics, the table disappears from the all_tab_modifications

    Thank you
    S

    Yes, makes the Act of analyzing a table disappears from the view of xxx_tab_modifications. It is because this view follows changes in the analyzed table have been modified in order to analyze the self employment can tell whether or not it must be analused "today."

    Assuming that you use more or less the default policy analysis that Oracle puts in place, it would be a pretty safe assumption that any which table not in xxx_tab_modifications had to be a substantial (as defined by the auto scan parameters) activity dml recently, or in other words did not have an important activity for a long time. You can make a difference based on the last_analyzed_date column in the xxx_tables view.

    John

  • How to get the old data 6 months from the current date?

    Hi friends,

    I have a table which includes historical data, which are having more than 1 years old data. The historical table gets updated once a week. My requirement is that I should get the latest data from the week of each month for 6 months according to the current data. I use oracle 10g.

    Can you please someone help in this.

    Thanks in advance

    SELECT last_day (ADD_MONTHS (TRUNC (SYSDATE, 'mm'),-LEVEL))-7 start_dt.
    LAST_DAY (ADD_MONTHS (TRUNC (SYSDATE, 'mm'),-LEVEL)) end_dt
    OF THE DOUBLE
    CONNECT BY LEVEL<=>

    change as a result, I have provided you the start and end dates for your logic...

  • I can not get the latest version of photoshop on my laptop, my office has 20151114.r.301 x 64 my can of laptop ONLY get 20150529.r.88 x 64

    I can not get the latest version of photoshop on my laptop, my office has 20151114.r.301 x 64 my can of laptop ONLY get 20150529.r.88 x 64.

    What gives?

    Hi again,

    Use this link to make a direct download - http://blogs.adobe.com/crawlspace/2011/03/keeping-photoshop-up-to-date.html#cc2015

    Concerning

    Rohit

  • I bought an upgrade from lightroom 5 to 6 (not cc) and when I try to update to get the latest patch for my camera (fujifilm t10) I am installer of clouds taken on creative and lightroom 6 cc and inviting me to open. nothing happens when I click on for the

    I bought an upgrade from lightroom 5 to 6 (not cc) and when I try to update to get the latest patch for my camera (fujifilm t10) I am installer of clouds taken on creative and lightroom 6 cc and inviting me to open. nothing happens when I click the icon. I had already downloaded a demo for creative cloud but decided against the purchase of this

    Hi artprints.

    You can install the update from Lightroom 6 from this link: keeping up-to-date for Lightroom

  • I have a monthly subscription of photography should I continue getting the latest updates?

    Can I get the latest updates for Photoshop CC with the monthly subscription of photography?

    Yes.

    Up-to-date (20141 CC 2014.1.1 CC for example) often invite you to install them automatically.

    New upgrades of version (for example Photoshop CC 2015) must be installed separately through the cloud desktop application, whenever you are ready to install.

  • Download all packages or just the sound with the latest dates?

    Hi, maybe it's a stupid question, but when you go to the drivers and it shows are all pilots who are selected to download to your laptop you wanted to install only those with the latest dates or each package that is there?

    Hello:

    You must install the driver with the most recent date if you are sure this is a driver that you are interested in.

  • Handycam DCR-PC55B where can I get the latest version of the software?

    I have a Sony Handycam DCR - PC55/B

    Where can I get the latest software and drivers for this?
    I'm running Windows 7 64

    I looked on the site and find several options, but as much as those to whom I am supposed to download I have no idea. I don't have the disk for the camera more. It works great however, I would just have any current to the extent where the drivers and editing software.

    Thank you for any assistance.

    I'll tell you this question as it solved. I could find my disc.

    That said, I still can't my videos from my camera to the PC. I don't know what to try next, it is a system Win7 64 and I don't think that one of the drivers for my camera is installed. However, when I look at my records I don't see any video transfer, but there is certainly video.

    I'll start a new topic, how can I transfer video to a Handycam DRC-PC55B to a Win7/64 PC and edit it?

    Thank you for your help.

  • Y at - it a newsletter I could sign up to get the latest beta versions of Microsoft?

    Y at - it a newsletter I could sign up to get the latest beta versions of Microsoft?

    No, it's not...

  • I do not trust the pop-up that wants to connect get the latest updates

    My password has been published on the internet and I had to change it. Now, I want to get the latest updates to Windows Live parental controls but I do not trust the pop up enough to give my new password.  Security Essentials says my own PC.

    This pop-up continues to appear in my children's accounts and asked me to sign.  It is getting more and more insistent and more frequent then put it in the background while we finish what we're doing.

    How can I get the updates without having to connect through the pop up?  I was hoping that I could do it here.

    Hello

    Sometimes, Family Safety application password of the parent for the latest updates. Family safety works with your account, so he needs the appropriate credentials to work properly.

    If the parental control invites you to ask you for the account and the password, please enter it for the latest updates in the parental control settings would be synchronized on your computer.

    Note: You can manually get updates for the safety of the family of

    update of the filter of parental control so that the changes will be reflected on the computer. To do this, please see the article below:

    How to update the family safety filter?

    Thank you!

  • Get the raw data to map its (SDK)

    I did a search on sound cards and many forums have been useful.  I have just a few quick questions.

    I have a card his (CardDeluxe http://www.digitalaudio.com/) connected to the computer through a PCI.  My goal is to get the raw data from the card and plug and it blow in analytics in CVI.  I don't know how to "talk" to my sound card.

    Of course, my main question is above, but to the refine some concerns...

    I guess I need the SDK libraries for that.  For this, I just need to install the MSN help libraries?

    Is this possible in the Basic Version, or if the full Package of CVI is necessary?

    I have not done things well at low altitude, but it looks like getting a wav file is necessary.  I can't use anything outside of the applications I want to eventually create a program automatically record and play at a time (sync) précis.

    Thanks in advance.

    This site is what I was looking for.  The zip file contains an exe as file c source code.

    http://paulhoule.com/phsrec/index.php

    Edit:

    There is also some info here - http://forums.ni.com/t5/LabWindows-CVI/wav/m-p/235344

  • problem to get the current date in qml

    Hello world

    I'm trying to get the current date in c ++ and qml and I used the class QDate, but it still has some problems:

    Code:

    =====================================================

    QDate * nowdate = new QDate;
    QDeclarativePropertyMap * nowdateMap = new QDeclarativePropertyMap;
    nowdateMap-> insert ("date", QVariant (nowdate-> currentDate()));
    QML-> setContextProperty ("nowdateMap", nowdateMap);

    ===========================================================

    After setting the nowdateMap, I'm able to get the date in the application, but the format is really weird, I did not use QDatetime, but the restult of shows like ' 2013-1 - 3 T 00: 00:00 ", how can I get rid of the final"T00:00:00 "? or is there a better way to get the current date?

    Thank you

    QDate nowdate is QDate::currentDate();.

    QString nowdatestring = nowdate.toString (); / / to get the date string format, you can define the shape of toString(), you can //search it
    QDeclarativePropertyMap * nowdateMap = new QDeclarativePropertyMap;
    nowdateMap-> insert ("date", QVariant (QString (nowdatestring)));
    QML-> setContextProperty ("nowdateMap", nowdateMap);

    then in the file qml, using nowdateMap.date will do.

  • How to get the last date of 3 days for the current month?

    Hello. Guy

    How to get the last date of 3 days for the current month?

    MY OUTPUT WOULD LOOK LIKE THIS

    JANUARY 29, 2016

    JANUARY 30, 2016

    JANUARY 31, 2016


    GUYS HELP ME / / /...

    SQL > select last_day (sysdate) - level + 1 double connect by level<= 3="" order="" by="">

    LAST_DAY)

    ---------

    29 JANUARY 16

    30 JANUARY 16

    31 JANUARY 16

Maybe you are looking for

  • All users 12.9 inch screen iPad Pro noted that it seems difficult more hard/more to own footprints on the screen?

    I use a cloth towel style is aggresiive a little more than a Microfiber cloth, because the Microfiber cloth was not a good job at all, the cleaning of the finger prints/finger oils out of my big iPad screen and even the fabric, I use now takes some t

  • Qosmio F750 - 12 p / BD - RW Pioneer BDR-TD04A - Bluray discs will not play

    Qosmio F750 - 12 pBD - RW Pioneer BDR-TD04AWindows 7 Home Premium Problem: Bluray discs will not play. CD will play. History: I did a clean install of Windows 7 and then installed 60 all the drivers from the support site for this laptop model. Or at

  • Tecra M3 recovery DVD-ROM

    Hello I just bought a brand new M3 in Germany and unfortunately found out that the operating system and the restoration of DVD - ROM is both in German. I contacted the support hotline just to hear that, as I bought it in Germany I could only receive

  • want to 700 = 147 c

    This pc has a digital cable to the monitor.  Electronic stores have different configurations of digital cable connectors.  What configuration is required and how to make a difference?  Otherwise, no matter what configuration will work?  I bought the

  • HP Pavilion: windows of 10 administrator password

    Set up a new computer for someone. Entered the password to use when signing - retyped it and used a hint. It has worked 3 times - now after that rebootng to install a program, it tells me the password is incorrect. Of course, never used a recovery di