Select the oldest date

Hi,
here is my question:
i create a table. for exemple : create table toto( id number (2)
, name varchar2 (10)
date_of_suscription date)
now i insert in this table :
insert into toto ( id, name, date_of_suscription ) values (1, 'yan', TO_DATE('12/20/2002 00:00:00', 'MM/DD/YYYY HH24:MI:SS'))
insert into toto ( id, name, date_of_suscription ) values (2, 'Mathieu', TO_DATE('10/10/2004 00:00:00', 'MM/DD/YYYY HH24:MI:SS'))
insert into toto ( id, name, date_of_suscription ) values (3, 'Steph', TO_DATE('06/04/1999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'))
insert into toto ( id, name, date_of_suscription ) values (4, 'mejdi', TO_DATE('05/17/2006 00:00:00', 'MM/DD/YYYY HH24:MI:SS'))
insert into toto ( id, name, date_of_suscription ) values (5, 'jérome', TO_DATE('10/12/2005 00:00:00', 'MM/DD/YYYY HH24:MI:SS'))
insert into toto ( id, name, date_of_suscription ) values (6, 'Patrick', TO_DATE('01/02/2000 00:00:00', 'MM/DD/YYYY HH24:MI:SS'))
insert into toto ( id, name, date_of_suscription ) values (7, 'Patrick', TO_DATE('03/12/2001 00:00:00', 'MM/DD/YYYY HH24:MI:SS'))
insert into toto ( id, name, date_of_suscription ) values (4, 'mejdi', TO_DATE('04/07/2009 00:00:00', 'MM/DD/YYYY HH24:MI:SS'))
if i want to get the oldest date_of_suscription for patrick (01/02/2000) without using : where date_of_suscription in min select from statement ? is there another method to do it ??

Use analytic queries:
with toto as (select 1 id, 'yan' name,  TO_DATE('12/20/2002 00:00:00', 'MM/DD/YYYY HH24:MI:SS') date_of_subscription from dual union all
              select 2 id, 'Mathieu' name,  TO_DATE('10/10/2002 00:00:00', 'MM/DD/YYYY HH24:MI:SS') date_of_subscription from dual union all
              select 3 id, 'Steph' name,  TO_DATE('06/04/2002 00:00:00', 'MM/DD/YYYY HH24:MI:SS') date_of_subscription from dual union all
              select 4 id, 'mejdi' name,  TO_DATE('05/17/2002 00:00:00', 'MM/DD/YYYY HH24:MI:SS') date_of_subscription from dual union all
              select 5 id, 'jérome' name,  TO_DATE('10/12/2002 00:00:00', 'MM/DD/YYYY HH24:MI:SS') date_of_subscription from dual union all
              select 6 id, 'Patrick' name,  TO_DATE('01/02/2002 00:00:00', 'MM/DD/YYYY HH24:MI:SS') date_of_subscription from dual union all
              select 7 id, 'Patrick' name,  TO_DATE('03/12/2002 00:00:00', 'MM/DD/YYYY HH24:MI:SS') date_of_subscription from dual union all
              select 4 id, 'mejdi' name,  TO_DATE('04/07/2002 00:00:00', 'MM/DD/YYYY HH24:MI:SS') date_of_subscription from dual)
-- end of mimicking data
select id, name, date_of_subscription
from   (select id, name, date_of_subscription, min(date_of_subscription) over (partition by name) max_dos
        from   toto)
where  name = 'Patrick'
and    date_of_subscription = max_dos;
        ID NAME    DATE_OF_S
         6 Patrick 02-JAN-02Edited by: Boneist on 18-Jun-2009 09:52
D'oh, you wanted the oldest date, not the latest date! Changed the max() to min()

Similar Messages

  • Entity Framework -  unable to select the oracle data connection

    Entity Framework - unable to select the oracle data connection from the wizard that allows you to select the data provider. Even though we successfully added a data connection that points to an oracle database, we still can't select an existing data connection or create a new database provider that points to an oracle instance.
    we are using both vs 2008 sp1 and vs 2010. We connect to oracle 11g and we use the latest oracle odp.net driver. the Driver is installed and working in vs studio.

    I had this exact problem when I started. I think I had downloaded the wrong odbc (the 64x version). When I unloaded that version and downloaded the 32bit version it worked.
    Hope that helps. ~ Darla

  • HT1766 Can I "restore" my "Notes" on my iPhone and select the backup date?

    Can I "Restore" ny "Notes" from my backup and can I select the backup date. e.g. Backup a few days old..
    Thanks

    Backups are incremental.  You cannot select a set date.  In addition, you cannot select to restore only notes.  You must restore everything.

  • Overwriting the oldest data in the file

    Hi,
      I have a file of 10MB want to write in to file continuously overwriting the oldest data, my file size should be maintained 10MB and program may run for quite long time. since i am new to labview used file operations, shiftregisters and little queues but i am not getting any satisfactory results, hopping my problem is simple and someone could help me on this.
    Thanks,
    ranjan.

    Well, we earlier solved it for the 20MB case, so the 10MB case should be trivial to solve.
    What is the structure of the file, are all records of equal lenght?
    Yes, most likely the solution is simple! Maybe you can show us your code that produces unsatisfactory results and tell us what kind of results would be satisfactory.
    LabVIEW Champion . Do more with less code and in less time .

  • To retrieve the oldest date in the report

    I have a requirement to retrive the oldest date in the report, I am currently working in BW 3.5
    The scenario is as below
    I have a char infoObject creation date which retrieves the date
    I have a char infoobject status which retrieves open or close
    For eg in my cube I have 5 records
    3 records has the status open and 2 records has the status closed
    When I adding the InfoObject "creation date" which has filtered for the open status , I am getting the result correctly with 3 records
    Now my requirement is I need to have only one row which should get oldest "creation date" out of the 3 records as below
    Rec1 10.10.2006
    Rec2 25.11.2007
    Rec3 20.08.2009
    I need only one count in the creation date which should show me 10.10.2006

    Hi Pavan.
    Can you model the creation date as a key figure as well as having it as a char? If so, you can create a condition on the key figure, to only give you the "Bottom 1" record.
    I think in 3.5 you cannot use a formula variable to read the value of the char in the row, but if you can, you can do it like that with a calculated key figure where you use the formula var and then put a condition on this ckf.
    regards
    Jacob

  • Compare Dates and select the max date ?

    Hello,
    I am trying to write a script and will compare the dates in " eff_startdt" and give me the lastest date at the outcome.
    I have data that some service locations have more than one contract date and I need to get the latest dated conract dates to work on the data but I tried many things I am always getting errors. When I run the script below I get " missing expression" error. I dont' see anything missing.
    also somehow Max() is keep giving me errors when I do something like [  ON service_locs = vmeterid WHERE SERVICE_LOCS = SERVICE_LOCS AND EFF_STARTDT = MAX(EFF_STARTDT)  ]
    Can someone pls give me advice on this. Thanks
    SELECT DISTINCT Broker, customer_name, service_locs, fee_kwh, qtr_monthly, eff_startdt, eff_enddt
    FROM VMETER
    INNER JOIN BROKER_DATA
    ON service_locs = vmeterid WHERE SERVICE_LOCS = SERVICE_LOCS AND (SELECT MAX(EFF_STARTDT) FROM VMETER)
    -----------------------------------------------------------

    Hi,
    I will try to explain on my example. I have got a table:
    DESC SOLD_ITEMS;
    Name                                    Value NULL? Type
    COMPONENT                                          VARCHAR2(255)
    SUBCOMPONENT                                       VARCHAR2(255)
    YEAR                                               NUMBER(4)
    MONTH                                              NUMBER(2)
    DAY                                                NUMBER(2)
    DEFECTS                                            NUMBER(10)
    DESCRIPTION                                        VARCHAR2(200)
    SALE_DATE                                          DATE
    COMP_ID                                            NUMBERI have insert example data into my table:
    select component, subcomponent, sale_date,comp_id
      2  from sold_items;
    COMPONENT       SUBCOMPONENT    SALE_DAT    COMP_ID                            
    graph           bar             06/04/03          1                            
    graph           bar             06/04/01          2                            
    search          user search     06/04/02          3                            
    search          user search     06/04/01          4                            
    search          product search  06/03/20          5                            
    search          product search  06/03/16          6                            
    graph           bar             06/05/01          7                            
    graph           bar             06/05/02          8                            
    graph           bar             06/05/02          9
    As you can see there are a few components and subcomponents duplicated with different date and comp_id value.
    I want to get component and subcomponent combination with latest date.
    SELECT COMPONENT, SUBCOMPONENT, MAX(SALE_DATE)
      2  FROM SOLD_ITEMS
      3* GROUP BY COMPONENT, SUBCOMPONENT;
    Efect:
    COMPONENT       SUBCOMPONENT    MAX(SALE                                       
    graph           bar             06/05/02                                       
    search          user search     06/04/02                                       
    search          product search  06/03/20
    For your purpose I will do it using join and subquery. Maybe it will help you resolve your problem:
    SELECT COMPONENT, SUBCOMPONENT, SALE_DATE, RANK
      2  FROM (SELECT T1.COMPONENT, T1.SUBCOMPONENT, T2.SALE_DATE,
      3          ROW_NUMBER() OVER (PARTITION BY T1.COMPONENT, T2.SUBCOMPONENT ORDER BY T2.SALE_DATE DESC) AS ROW
      4          FROM SOLD_ITEMS T1, SOLD_ITEMS T2
      5          WHERE T1.COMP_ID = T2.COMP_ID)
      6* WHERE ROW = 1;
    I joined the same table but it act as two different tables inside subquery. It will group values (partition by statement) and order result descending using t2.sale_date column. As you can see columns are returned from both tables. If you would like to add some conditions, you can do it after WHERE ROW=1 code.
    Results:
    COMPONENT       SUBCOMPONENT    SALE_DAT       RANK                            
    graph           bar             06/05/02          1                            
    search          product search  06/03/20          1                            
    search          user search     06/04/02          1Hope this help you
    Peter D.

  • How to select the latest date for a field in CR?

    Dear all expert.
    I need to develop a report where it only show the latest date. For example, I had a report, it contain a customer description and bussiness transaction posting date.
    Customer description           BT posting Date
    A                                          03/10/2010
    A                                          15/10/2010
    A                                          23/11/2010
    A                                          24/12/2010
    A                                          30/12/2010
    A                                          15/02/2011
    A                                           20/03/2011
    B                                           20/03/2011
    B                                           02/04/2011
    B                                           08/04/2011
    B                                           11/04/2011
    But in CR, i Just wan it to show me:
    Customer description          BT posting Date
    A                                         20/03/2011
    B                                         11/04/2011
    I just want to show customer with the latest BT posting Date, How can I do that?
    Thank You.

    Hi Alex,
    If you want to show the data only in Detail other than group then you may follow the following :
    --Create a group on Curstomer Descripton
    --Createa fromula : Maximum(,)
    --Go in Section Expert -- suppress condition -- then give a condition like :
      <>  Maximum(,)  //  'not equal'
    This will suppress other dates and give you the latest date on your detail.
    Thanks,
    Sastry

  • Send an internal mail (SAP inbox) to a user and select the expire date

    Hello!,
    This is my first question in this forum. I need to send an internal mail to a user and I must insert a expire date.
    I try to use the FM 'SO_OBJECT_SEND' and it's works but I don't know where I can insert the expirte date.
    Can you help me?, please.
    Thanks a lot.

    Hi,
    Try this..
    In the parameter OBJECT_HD_CHANGE there is column DLDAT (Expiry date) & DLTIM (Expiry time)...Give the date and time in this column and then check..
    THanks,
    Naren

  • Selecting the XML data from a drop-down menu or links

    Hi, I have this page:
    http://www.georgeglazer.com/prints/nathist/botanical/volckinv/volckinv.html
    There are prints of lemons/limes and prints of oranges. I
    want to have the visitor select which kind of fruit from either a
    drop-menu or from two links that look something like this:
    Lemons/Limes | Oranges. Looking at other help docs I found the
    region/state mapping demo at
    http://labs.adobe.com/technologies/spry/samples/data_region/StateMappingSample.html,
    and copied the code and tried to modify it. But I don't really
    understand the technical shorthand of the help docs (an ongoing
    problem I have with the Spry documentation) and I couldn't find the
    XML docs that the region/state mapping demos are based on so I
    couldn't see how they were set up.
    I got as far as this: nothing loads initially when you open
    the page (I'd like the lemons to load), but if you select Oranges
    from the drop-down menu you see the oranges, and THEN once you've
    done that, you can select Lemons/Limes in the drop-down menu and
    see those. I have three XML files I've been playing around with to
    get this to work: lemons.xml, oranges.xml and inventory.xml, which
    combines the two.
    I also suspect region/state mapping might not even be exactly
    what I'm trying to do here, but I can't figure out from the
    documentation exactly what this thing I'm trying to do is called. I
    know the photo album demo accomplishes something similar, and I
    could do that, but it seems way more complicated than what I need
    here (right?). Help will be appreciated!
    Thanks,
    Helen

    I made a different test using the file
    http://www.georgeglazer.com/prints/nathist/botanical/volckinv/inventory.xml
    and
    http://www.georgeglazer.com/prints/nathist/botanical/volckinv/volcktest.html
    where I sent up the inventory xml form like one I found in the
    Nested XML Data documentation where you have item ids and types, so
    all the oranges and lemons are in one XML document (which I'd
    prefer).
    Here's an abbreviated version of the inventory.xml:
    <inv_items>
    <inv_item id="1" type="lemon">
    <name>Lemons and Limes</name>
    <title>Cedro Ordinario</title>
    <plate>116a</plate>
    <fullimage>pl116a.jpg</fullimage>
    <tn>pl116a-2.jpg</tn>
    </inv_item>
    [and more lemons follow]
    <inv_item id="19" type="orange">
    <name>Oranges and Others</name>
    <title>La Zucchetta Imperiale</title>
    <plate>138a</plate>
    <fullimage>pl138a.jpg</fullimage>
    <tn>pl138a-2.jpg</tn>
    </inv_item>
    [and more oranges follow]
    </inv_items>
    What I'd like to do is display the names "Lemons and Limes"
    and "Oranges and Others" and when you click on "Lemons and Limes"
    you see only the thumbnails for lemons and limes, and when you
    click on "Oranges and Others" you see the thumbnails for only
    those. I'd like the Lemons and Limes to be selected when the page
    is opened.
    Help greatly appreciated!

  • Drop down selection is not refreshing the page data correctly

    I have a drop down menu for a CREATE DATE. The record is based on a Identification ID. This identification ID can be in our system for multiple CREATE DATES. The CREATE DATE drop down is populated by checking how many different CREATE DATES there are for a particular identification ID.
    The last identification ID looks great. It populates all the fields. However if you select an older CREATE DATE, the page does not get populated with that CREATE DATES data. The whole page even looks different. It looks like an older version of the page before I added all the new fields.
    What is causing the older CREATE DATES not to look like the current create date.
    Please let me know if you need any additional information. Thank you!!
    Pattibz

    Thank you for your reply. Here are some details. Please let me know if I am not giving the information you need.
    One page item called CREATE_DATE displayed as a Select LIST with submit. The source type is a database column called ID_IDENT. The ID_IDENT is just a
    The List of Values is: Named LOV is the Select Named LOV. The list of values definition is a query against a table in our database:
    select CRE_DT, ID_IDENT from IDENT_TABLE where UNIQ_ID = :P3_UNIQ_ID
    ORDER BY CRE_DT DESC
    This is the date on which the ID_IDENT data was created. The date is displayed in a pull down menu, which allows you to select from a list of available "as of" dates when viewing the data. Only data on the most recent ID_IDENT record may be manually altered.
    I have a UNIQ_ID = '34587443'. It acutally has records in the database with that UNIQ_ID. The only difference is the create date. On record of 345778 was done on 10/1/2008 and the current date 10/13/2008.
    I see these two dates in the CREATE_DATE pull down menu. This is fine. The drop down orders the dates by DESC so I have the lastest date on top fo the pull down.
    If I want to pick the date of 10/1/2008, I need go into the web page, open the Create Date pull down and select the older date.
    When I pick the older date 10/1/2008, the page does not look the same as the defaul tor oldest time date and numbers.
    The page is different and most of the data on the webpage is there.
    What should have happened is that I choice the newer date from the drop down, the page refreshes with the data from 10/1/2008
    and all the parameters are displayed from the date of 10/1/2008. It isn't only part of the fields are being populated and the page itself doesn't refresh to the look of the original page. Thank you.
    Edited by: pattibz on Sep 12, 2008 11:15 AM

  • How to pass the selected table row data from popup to source view

    Hi ,
    I have requirement of passing the data from popup view to source. , searching some data in  popup view and displaying in table,
    Like i am passing some input and click search button will display the data in table, when select any of the row in the table and click on the another button , i should be able to pass the select row to the source view and also should close the popup.
    When i implement , In the popup windiw, when i enter the customer no, and click on search button, it is closing the popup itslef. not able to see the data in popup.
    Can u tell me what is that soultion.
    Regards
    Vijay

    Hi Harsimran
    Thanks for the reply,
    1) Source view
    In  "Source View" i have input field called Customer_no. But,  the end user will not have any idea , what customer no to enter. so i am searching the customer no in the popup view.
    1) Customer_no( This is an inputfiled , to get the customer no from the popup view)
    2) Get Customer NO( This is a button to call the popup view)
    "Get Customer NO" This button action will open the popup view.
    In this popup, i have
    1) Input field (To enter the search term)
    2) Search (To seach the customer no based on the search term)
    3) Table ( To display the search data)
    4) Button in Table tool bar called "Select" .( To close the popup view after selected the required data in the table to pass it back to the source view).
    so in the popup view what happening is, when i click on the search button itself , it is closing the popupview  by transfering the first row of the tbale ,with out select the required row in the table.
    i need to close the window after click on the "Select" button in the toolbar , after selected the required row data to trasfer in the table.
    Can u pelase tell me what are the modifcations i need to do it.
    Regards
    Vijay

  • To find the greatest date from table

    guys,
    I currently use this query to find the difference between sysdate and the oldest date in the table
    select (SYSDATE - cur_date) from comp_check
    the problem is it fives multiple records as output.
    i want to design a query that will give the difference between sysdate and the oldest date in the table(it should throw only one record as the result)
    how do i do that.
    thanks in advance

    SQL> select sysdate-min(created) from all_users
    SQL> /
    SYSDATE-MIN(CREATED)
              507,373866
    SQL> Nicolas.
    MIN usage for oldest. Correction after ennisb's remark, thanks.
    Message was edited by:
    N. Gasparotto

  • Infotype Header Data - Cost center- System to read the latest data

    Dear Group Members,
    I am modifying Infotype Header data and calling Cost center (Field - KOSTL) in header data via modifying header data in   table T588J. The cost center values appears on the  header data (As stored in Infotype 0001) however it appears with the oldest data. i.e. if the employee cost center had been changed after his joining system does not picked up the Latest data/ Latest cost center value.
    Any one on how to resolve this issue with SAP Standard functionality.
    Regards
    VISHAL SAXENA
    SAP Specialist - HCM

    Hi,
    The answer to your question lies in table V_582A_B. You can either access it through SM30 or by following IMG path:
    SPRO>Personnel Management>Personnel Administration>Customizing User Interfaces>Change Screen Header>Header structure per infotype
    There is a u201Cchoose datau201D indicator for each infotype. If that is checked, the header displays data as per the start date of infotype displayed; otherwise, it shows data valid as of system date. Please bring up SAP help on the field by F1 for more information.
    Also check table T588H (data selection field) as it has some dependencies for the above mentioned settings. The table can be brought up from:
    SPRO>Personnel Management>Personnel Administration>Customizing User Interfaces>Change Screen Header> Infotype header data selection control
    Hope this helps.
    Donnie

  • How do I set all photos in a project to the same date (rather than simply time-shifting)?

    I have a bunch of old scanned photos in Aperture (current version - 3.5.1), and am trying to tidy up the metadata, especially the dates.
    This is turning out to be quite a task, as the date gaps between scans are all over the place. For example, in one project I might have photos scanned between 2004 and 2007 that all took place on one day in 1999.
    This means the native "adjust date and time" function in the metadata menu doesn't work, as it is a little too clever in its timeshifting. If I highliht the whole project and change it all to 1 June 1999, the 2004 shots get changed to that date but the 2007 scans are dated 2002, with Aperture "cleverly" preserving the inaccurate three year gap in the original scans' metadata.
    This is making the process of fixing my data far more arduous than it needs to be.
    I feel like my situation can't be that unusual, and their must be a way to override this behaviour. I'm not fussy about preserving logical time gaps between shots  but I'd like them to have the right year and month (so a "dumb" solution that gave them all idntical date and times would be fine).
    Can anayone help? Thanks in advance!

    What is your Aperture version?
    If it is compatible with iPhoto, open the Aperture library in iPhoto and use iPhoto's Batch Change to adjust the date of your scans:  (File > Open Library in iPhoto)
    In iPhoto select the photos in the event and go to the main menu bar:
    Photos  > Batch Change > Set Date:
    Select the initial date and time of your photos and a very small gap, e.g. 1 second. All photos will set to the same date, stepped by one second to preserve their time order.
    Afterwards switch back to Aperture using "File > Open Library in Aperture).
    this works very well with Aperture 3.5.1 and iPhoto 9.5.1.
    -- Léonie

  • How to get the default date as current date in input filed in VC

    Hi
    In my VC application i have two date fields. we are allowing the end user to select the From Data and Todate though Data pickers, But the client asking to make the today's date as default date in Todate field , rather picking up from the data picker,
    Unless the  user wants change the todate from the current date. It should display today's date as default date.
    can any body tell me how to do it.
    Regards
    Vijay

    Hi All,
    I have an issue an implementing the "Exporting the Table data to Excel."
    My VC version is 7.0
    Portal version NW 2004s.
    By refering the following link, i have implemented Export To Excell functionality in VC.
    2) Another one that's in the Visual Composer WIKI:
    https://wiki.sdn.sap.com/wiki/display/VC/Exportingdatafrom+VC
    By refering to 7th page in the document. It is explained to add the data source object from the 'info' port and add the field called 'RAPTNAME'to the DATA source object.
    But the RFC object which i added to the story board, i havent find any 'info' port in my added RFC. But still i have added the data store object and added field. then
    copied the following given formula in the document in respective formula window ,Formula showin as valid. when i click on check button.
    copied formula :
    "pcd!3aportal_content!2fcom.sap.pct!2fplatform_a
    dd_ons!2fcom.sap.ip.bi!2fiViews!2fcom.sap.ip.bi.b
    ex?QUERY=" & STORE@REPTNAME &
    "&BI_COMMAND_1-
    BI_COMMAND_TYPE=EXPORT&BI_COMMAND
    1-EXPORTFORMAT=XLS&BI_COMMAND_1-
    null="
    i am able to run the application. After i run the application . once i click on the button 'ExportToExcel' i am getting the following error.
    Portal Runtime Error
    An exception occurred while processing a request for :
    iView : N/A
    Component Name : N/A
    Could not find portal application com.sap.ip.bi.service.generic.
    Exception id: 05:32_01/05/07_0001_18800950
    See the details for the exception ID in the log file
    Can u please tell me what is the problem
    Regards
    Vijay

Maybe you are looking for

  • How can i get back my data after i restored my iphone and accidentally created a new iphone ac.

    how can i get back my data after i restored my iphone and accidentally created a new iphone ac. it did a back up when i started my restored iphone and i cant retrieve my previous backup while i didnt back up on icloud.... the new ac is actually the s

  • Adobe Reader 9 installed but can't open any pdf. file now

    I have been successfully using the Acrobat Adobe 8 with no problem until trying to download the Adobe Reader 9. I run on Windows XP.  Ever since downloading Adobe Reader 9....I can no longer use Acrobat Adobe at all.  I can not read or open any Acrob

  • Images or pdf not inserted anymore in Mail

    Hello, my images or PDF are not "inserted " in my mail messages anymore the only show as an attachment How do I bring back the "inserted" what terminal commandto re-activate "insert docs (jpg, QT, PDF) within email

  • Retrieving already purchased music

    Good Day, I purchased an album on iTunes, a month later I lost all my data and iTunes when my unit crashed. How can I retrieve this album without buying it again? Surely there is a way this can be accomplished, can someone please help me with this ch

  • ApplicationLoader - Icon specified in the Info.plist not found

    Fellow developers, Have any of you seen this error when trying to upload the app using the ApplicationLoader: Icon specified in the Info.plist not found: iconplus The icon file is there and has always loaded just fine on the emulator. I entered the f