How to select Most recent record with rest of record in ascending order...?

Dear Expert,
I have one table called Tab1 & have a lot columns. For this schenario, i mentioned few of the columns.
The columns are
product_type varchar2(100),
curr_date date (storing with time stamp),
other1_cloumn varchar2(10),
other2_cloumn varchar2(10)
Now I want to display all the records in ascending order except most recent record for every product_type || Union all || Most recent records in ascending order in single query.
For example...
product_type curr_date date other1_cloumn other2_cloumn
1, "10-May-2005 10:10:10", 10, 10
1, "10-May-2005 10:10:11", 10, 10
1, "10-May-2005 10:10:12", 10, 10
1, "10-May-2005 10:10:09", 10, 10
2, "10-May-2005 10:10:10", 10, 10
2, "10-May-2005 10:10:11", 10, 10
2, "10-May-2005 10:10:12", 10, 10
2, "10-May-2005 10:10:09", 10, 10
3, "10-May-2005 10:10:10", 10, 10
3, "10-May-2005 10:10:11", 10, 10
3, "10-May-2005 10:10:12", 10, 10
3, "10-May-2005 10:10:09", 10, 10
Now I want to display (OUTPUT) like...
1, "10-May-2005 10:10:10", 10, 10
1, "10-May-2005 10:10:11", 10, 10
1, "10-May-2005 10:10:09", 10, 10
2, "10-May-2005 10:10:10", 10, 10
2, "10-May-2005 10:10:11", 10, 10
2, "10-May-2005 10:10:09", 10, 10
3, "10-May-2005 10:10:10", 10, 10
3, "10-May-2005 10:10:11", 10, 10
3, "10-May-2005 10:10:09", 10, 10
1, "10-May-2005 10:10:12", 10, 10
2, "10-May-2005 10:10:12", 10, 10
3, "10-May-2005 10:10:12", 10, 10
Plz, provide a solution....

I want to display like...
select * from tab1 where (product_type,curr_date) in
(select product_type,max(curr_date) from tab1 group by product_type)
order by product_type
Union All
(select * from tab1 where (product_type,curr_date) NOT IN
(select product_type,max(curr_date) from tab1 group by product_type)
order by product_type)
But, In the above case, The ORDER BY Clause will not work...How to get this one...?
I mean.. I want to display all the records in ascending order except Most recent record base on Product type and next I want to display Most recent record in ascending order. I want to display both cases in a single query...?

Similar Messages

  • Select "most recent" records in abap

    Hi
    how can I select the most recent records in a table by using the abap select statement.
    Example: The 100 rows with the "highest" (most recent) sequence-numbers in a table with documents.
    somehow like this:
        SELECT "most recent" * FROM draw
        INTO TABLE gt_doklist
        UP TO 100 ROWS
        where ...
    Has anybody an idea?
    Thanks in advance,
    Willi

    Actually I believe that all the answers are wrong.
    I believe that there will never be a single statement. If you need to determine the last 100 records for a special user you first need to determine the highest document number.
    this can be done by
    select max( document_number ) into document_number from table where username = username.
    Any descending sorting order or group by etc. will never make sure that you get the last one. For a simple reason What should the select statement look like that makes sure (in combination of any cursor applied)? Its impossible!
    If you now need the latest 100 records for a single user its the same problem like buffered number ranges. There is no way to perform that task because there is no database routine or sql statement to do so. And 1.5 million records are too much to try out or select everything.
    You could do an assumption that the last 100 for that user have been posted during the last 1000 or last 10.000 records, select them and filter out.
    Alternative you can perform the following select statement for 100 times. Using an index on document number and user might not be such a performance killer if its only done for one user during his online dynpro process:
    data: max_number type char10.
    select max( documentnumber ) into max_number from table
      where username = username into [structure].
    max_number = max_number + 1.
    do 100 times
    select max( documentnumber ) from table intomax_number
      where username = username and docnumber lt max_docnumber.
    select * from [db_table] into [structure] where docnumber = max_number.
    append [structure] to [table].
    enddo.
    Of course that just draft coding... apply if statements and so on...
    Even though its pretty poor, its the only way to do. Any select statement will never garantee what records you will get if you do not restrict accordingly and if the restriction has to be made on document number, but if there is no way to get the max_number - [100 last records of this user], there is no solution using one statement.
    Thats it.
    Edited by: Rob Burbank on Feb 25, 2010 8:52 AM

  • I pre-ordered the most recent City and Colour album. When i ordered the album the funds were immediately withdrawn but now, when trying to download my pre-order, I am being asked to purchase the album again. How do I not pay for the album twice?

    I pre0ordered the most recent City and Colour album. When i ordered the album, the funds were withdrawn immediately. When trying to download the pre-order I am being asked to pay for it again. How do i stop this?

    No I haven't, the usual button that says PURCHASE still says PURCHASED. Have you found any solutions? I would greatly appreciate your help with this and I will do the same.

  • Sync P info records with Q info records

    Hi Gurus,
    Can any suggest how we can sync P info record with Q info record?
    We have data maintained correctly for all vendor information and not
    maintained properly in P info record but maintained correctly in Q info record.
    Please suggest
    Thanks & Regards,
    Rajesh

    Hi Jurgen,
    Yes i agree. We wanted to have Purchase info record created when we have Q info record.
    Is there a way where we can do it?
    Please let us know.
    Thanks in Advance
    Thanks & Regards,
    Rajesh.

  • TS1424 there are 43 available apps' update  which couldn't be made with my current account. How i can find the account with which i bought them in order to update them

    there are 43 available apps' update  which couldn't be made with my current account. How i can find the account with which i bought them in order to update them

    Use get info in iTunes on your Mac.

  • How to get most recent consecutive records with the same value

    Hi,
    Can someone please help me to solve my problem?
    Below is my table
    Prod_Code-----Purchase_date---Inv_number-------Inv_amt
    MS_AV16850------18/01/2005-----------6575947----------------7.93
    MS_AV16850------22/07/2005-----------7034012----------------51.82
    MS_AV16850------04/01/2006-----------8719618----------------51.82
    MS_AV16850------20/06/2006-----------9515864----------------104.69
    MS_AV16850------16/04/2007-----------10353759----------------189.29
    MS_AV16850------30/05/2007-----------10689899----------------189.29
    MS_AV16850------06/01/2008-----------1653821----------------65.49
    MS_AV16850------22/02/2009-----------10866311----------------189.29
    I want my query to show the rows that has most recent purchase dates with same amount in consecutive purchase date.
    So from the table above, the query should display:
    Prod_Code-----Purchase_date---Inv_number-------Inv_amt
    MS_AV16850------16/04/2007-----------10353759----------------189.29
    MS_AV16850------30/05/2007-----------10689899----------------189.29
    It should not get
    MS_AV16850------16/04/2007-----------10353759----------------189.29
    MS_AV16850------30/05/2007-----------10689899----------------189.29
    MS_AV16850------22/02/2009-----------10866311----------------189.29
    because inv_number 10866311 has a prvevious inv_amount of 65.49.
    and not get this
    MS_AV16850------22/07/2005-----------7034012----------------51.82
    MS_AV16850------04/01/2006-----------8719618----------------51.82
    because they are not the most recent purchase date even if they have the same inv_amount.
    Thanks in advance.

    Hi,
    You're right; thanks for catching my mistake.
    I changed the WHERE clause of the main query (including subquery there) to deal with that situation:
    WITH     got_grp          AS
         SELECT      x.*
         ,      ROW_NUMBER () OVER ( ORDER BY      purchase_date )
                - ROW_NUMBER () OVER ( PARTITION BY  inv_amt
                                             ORDER BY         purchase_date )     AS grp
    --     ,      ROW_NUMBER () OVER ( ORDER BY      purchase_date )     AS r1
    --     ,        ROW_NUMBER () OVER ( PARTITION BY  inv_amt
    --                                         ORDER BY         purchase_date )     AS r2
         FROM     table_x     x
    SELECT     *     -- Or list all columns except grp
    FROM     got_grp
    WHERE     (inv_amt, grp)  IN  (
                               SELECT    MAX (inv_amt) KEEP (DENSE_RANK LAST ORDER BY MAX (purchase_date))
                        ,       MAX (MAX (grp))
                                FROM      got_grp
                                GROUP BY  grp
                                ,       inv_amt
                                HAVING    COUNT (*)     > 1
    ;Thanks, too, for posting the sample data. Apparantly, you're more interested in solving this problem than OP is.
    Edited by: Frank Kulash on Nov 22, 2010 1:36 PM
    The r1 and r2 columns are not needed for the solution. You may want to display them, just to help see how the query works.

  • Select most recent record prior to a target date

    Let's say I have a set of unique records with the following dates:
    11/15/08
    11/30/08
    Is it possible to select only the most recent record prior to a user-entered target date (e.g., 12/1/08)?  So in this case, only the record dated 11/30/08 would be selected for the report.

    Use the record selection formula like this
    {Date field}<={?Date Parameter}
    And also wrtite the group selection formula like this
    {Date field}=maximum({Date field})
    This returns the recent value nearer to the date entered in the prompt.
    Regards,
    Raghavendra

  • How to determine most recent date from the date column of internal table

    Dear friends
    would you like to tell me. how i determine the most recently changed record by looking at date and time from internal table i am not supposed to sort the table by date and time... I must check date and time with other records date and time to determine which record is most recently changed...
    here the scenario is.
    id idnumber chdate chtime
    1 123456 20060606 135312
    2 123456 20060606 135900
    3 123456 20060606 132300
    4 123457 20060606 140000
    5 123457 20060606 142500
    in the above scenario i must keep in my mind that the most recently changed record is identical to its idnumber i can say that:
    the record should be fetched this way
    id idnumber chdate chtime
    3 123456 20060606 132300
    5 123457 20060606 142500
    because here the id 3 is the most recently changed in the idnumber 123456
    where id 5 is the most recently changed in the idnumber 123457
    please help me to determin how i am supposed to carry out this task any suggestion, code will be great help of mine.
    regards
    Naim

    After testing my suggestion above, I realized that it doesn't work because the delete adjacent actually will keep the first one and delete the rest.  I'm working with Srinivas's code a bit now,  I think it is almost what you want.  I am under the impression that you dont' want to HIGHest date/time, but just the last record of the sequence, if this is the case, then this code will help.  Here we will assign an index to each record per the idnumber, that way we can sort it and get the lastest record.
    report zrich_0001.
    types: begin of itab_type,
            id       type i,
            idnumber type i,
            chdate   like sy-datum,
            chtime   like sy-uzeit.
    types: end of itab_type.
    types: begin of itab_type2,
            id       type i,
            idnumber type i,
            index    type i,
            chdate   like sy-datum,
            chtime   like sy-uzeit.
    types: end of itab_type2.
    data: itab     type table of itab_type with header line,
          itab2    type table of itab_type2 with header line,
          prev_rec type itab_type.
    data: v_id type i.
    start-of-selection.
      itab-id       = 1.
      itab-idnumber = 123456.
      itab-chdate   = '20060606'.
      itab-chtime   = '135312'.
      append itab. clear itab.
      itab-id       = 2.
      itab-idnumber = 123456.
      itab-chdate   = '20060606'.
      itab-chtime   = '135900'.
      append itab. clear itab.
      itab-id       = 3.
      itab-idnumber = 123456.
      itab-chdate   = '20060606'.
      itab-chtime   = '142500'.
      append itab. clear itab.
      itab-id       = 4.
      itab-idnumber = 123457.
      itab-chdate   = '20060606'.
      itab-chtime   = '140000'.
      append itab. clear itab.
      itab-id       = 5.
      itab-idnumber = 123457.
      itab-chdate   = '20060606'.
      itab-chtime   = '120000'.
      append itab.
      clear itab.
    <b>  data: counter type i.
    * Assign an index to each row per idnumber
      loop at itab.
        on change of itab-idnumber.
        if sy-tabix > 1.
          clear counter.
          endif.
        endon.
        clear itab2.
        move-corresponding itab to itab2.
        counter = counter + 1.
        itab2-index = counter.
        append itab2.
      endloop.
    * Sort it and get rid of older records.
      sort itab2  by idnumber ascending
                     index descending.
      delete adjacent duplicates from itab2 comparing idnumber.</b>
      read table itab2 with key idnumber = '123456'.
      write:/ itab2-chdate, itab2-chtime.
      read table itab2 with key idnumber = '123457'.
      write:/ itab2-chdate, itab2-chtime.
    Regards,
    Rich Heilman

  • Previous month is easy, what about most recent date WITH data?

    As the topic suggests, I've seen many posts with the following solution for returning the last date of the previous month: TIMESTAMPADD(SQL_TSI_DAY,DAYOFMONTH(CURRENT_DATE) * -1 , TIMESTAMPADD(SQL_TSI_MONTH, 1, CURRENT_DATE)).
    However, for at least the first few days of the current month, no data will be available for the previous month. How can I tell OBIEE to return the date for the most recent month where data exists?
    Another part of this puzzle, is that this request needs to play nicely with query rewrite in the view. the TIMESTAMPADD doesn't seem to use query rewrite well. Any suggestions?

    jzuzphreek wrote:
    As the topic suggests, I've seen many posts with the following solution for returning the last date of the previous month: TIMESTAMPADD(SQL_TSI_DAY,DAYOFMONTH(CURRENT_DATE) * -1 , TIMESTAMPADD(SQL_TSI_MONTH, 1, CURRENT_DATE)).
    However, for at least the first few days of the current month, no data will be available for the previous month. How can I tell OBIEE to return the date for the most recent month where data exists?
    Another part of this puzzle, is that this request needs to play nicely with query rewrite in the view. the TIMESTAMPADD doesn't seem to use query rewrite well. Any suggestions?For what you presented, the answer is simple. However, I suspect that your need is not as simple as you described. You describe your scenario as "there are no data for the previous month for the first few days of the current month." There are two inherent assumptions which if true, makes the problem not that difficult:
    1) Only the first few days of the current month, there are no data for the previous month (i.e., for the rest of the month, the data are there.)
    2) Data exists for every month.
    With these two assumptions, here is how you build your dashboard.
    1) Create a simple report with the key data fields run with the filter for "current month."
    For the "first few days" of the current month, this report will yield no records. (It doesn't matter how many days "a few days" is as you will see.) For the "rest of the month," this small report will always yield at least one record.
    2) Create your main report (call this Report A) that has a filter for "previous month."
    3) Place Report A on your dashboard in a Section.
    4) Click on the Properties of the Section and select "Guided Navigation" and have it point to the small report you built in step 1) that will display the section "if the request returns rows."
    5) Build another report (call this Report B) that has a filter for "two months ago."
    6) Place Report B in a separate Section on your dashboard, below the Section in step 3).
    7) Click on the Properties of this Section and again select "Guided Navigation," have it point to the small report from step 1), but this time have it display "if the request returns no rows."
    So here's what happens. For the first few days of "this month," the small report will return no rows. The top Section will not display, but the bottom one will, which has as its filter "two months ago." The assumption is that by the end of each month, there will always be data. This therefore meets your criteria of displaying "the most recent month where data exists." Once data for "this month" is available, the top Section will display with the current month's filter. The bottom section will not appear until the "first few days" of the next month.
    That's how you do it.

  • Select most recent DATE for an ID.

    Hi All,
    I need to SELECT the records with the most recent DATE for each ID. A DATE range is part of the selection criteria.
    My data.
    MY_ID MY_DATE
    1684662 26-JAN-09
    1424097 27-JAN-09
    1684663 27-JAN-09
    1684664 27-JAN-09
    1684672 28-JAN-09
    0689073 28-JAN-09
    1052476 21-JAN-09
    1052476 21-JAN-09
    1360828 23-JAN-09
    1684661 23-JAN-09
    1052476 30-JAN-09
    1052476 30-JAN-09
    1052476 30-JAN-09
    1052476 30-JAN-09
    The code below works fine when selecting 1 ID in the SUBSELECT, but with multiple ID it still selects rownum=1 (of course). This as far as my thinking takes me.
    SELECT my_id,
    my_date
    FROM
    (SELECT my_id,
    my_date
    FROM my_table
    ORDER BY my_date DESC
    WHERE rownum = 1
    AND *{color:#ff0000}my_id = 1052476{color}*
    AND TO_CHAR(my_date,'YYYY/MM/DD') BETWEEN '2009/01/01' AND '2009/01/31';
    If I could somehow pass the SELECT ID into the SUBSELECT WHERE clause I should have this done.
    Any suggestions?
    Thank You in Advance for Your help,
    Lou

    One of many possible soultions.
    ME_XE?with data as
      2  (
      3     select 1684662 as id, to_date('26-JAN-09','dd-mon-yyyy') as the_date from dual union all
      4     select 1424097 as id, to_date('27-JAN-09','dd-mon-yyyy') as the_date from dual union all
      5     select 1684663 as id, to_date('27-JAN-09','dd-mon-yyyy') as the_date from dual union all
      6     select 1684664 as id, to_date('27-JAN-09','dd-mon-yyyy') as the_date from dual union all
      7     select 1684672 as id, to_date('28-JAN-09','dd-mon-yyyy') as the_date from dual union all
      8     select 0689073 as id, to_date('28-JAN-09','dd-mon-yyyy') as the_date from dual union all
      9     select 1052476 as id, to_date('21-JAN-09','dd-mon-yyyy') as the_date from dual union all
    10     select 1052476 as id, to_date('21-JAN-09','dd-mon-yyyy') as the_date from dual union all
    11     select 1360828 as id, to_date('23-JAN-09','dd-mon-yyyy') as the_date from dual union all
    12     select 1684661 as id, to_date('23-JAN-09','dd-mon-yyyy') as the_date from dual union all
    13     select 1052476 as id, to_date('30-JAN-09','dd-mon-yyyy') as the_date from dual union all
    14     select 1052476 as id, to_date('30-JAN-09','dd-mon-yyyy') as the_date from dual union all
    15     select 1052476 as id, to_date('30-JAN-09','dd-mon-yyyy') as the_date from dual union all
    16     select 1052476 as id, to_date('30-JAN-09','dd-mon-yyyy') as the_date from dual
    17  )
    18  select id, the_date
    19  from
    20  (
    21     select id, the_date, max(the_date) over (partition by id) as max_the_date
    22     from data
    23  )
    24  where the_date = max_the_date;
                    ID THE_DATE
                689073 28-JAN-0009 12 00:00
               1052476 30-JAN-0009 12 00:00
               1052476 30-JAN-0009 12 00:00
               1052476 30-JAN-0009 12 00:00
               1052476 30-JAN-0009 12 00:00
               1360828 23-JAN-0009 12 00:00
               1424097 27-JAN-0009 12 00:00
               1684661 23-JAN-0009 12 00:00
               1684662 26-JAN-0009 12 00:00
               1684663 27-JAN-0009 12 00:00
               1684664 27-JAN-0009 12 00:00
                    ID THE_DATE
               1684672 28-JAN-0009 12 00:00
    12 rows selected.
    Elapsed: 00:00:00.03

  • Most recent date with two other conditions met

    Ok, so I'm sure somebody is going to suggest that I do a search first before posting on here.  So let me assure you, that I have exhausted all search possibilities that I could possibly think of before registering to post on here.  I've read a lot of good suggestions that got me just as far as I was getting on my own, because I couldn't find any posts of somebody asking exactly what I'm looking to do.  I have tried quite close to 100 different formulas without achieving the desired results.
    I'm a pilot, and I track all of my flights myself in a very well organized(I think so ) Numbers spreadsheet that I've been tweaking and perfecting over the past few years.  I have created plenty of formulas in it, and they all work great...except ONE.
    I've created a simplified version of the columns I am trying to match specific conditions with.  Essentially, I need the formula to return the most recent date(column 1), that is completed during a night time flight status(column 2), that is equal to or greater than 1.0 flight hours(column 3).
    As you can see, by evaluating the table below, the correct formula should return to me:        8-4-13
    The closest I've come to getting the correct results was with a "LOOKUP" formula, but I could not figure out how to get it to properly assess whether it was equal to or greater than 1.0 hours of flight, thus returning me the wrong date EVERYTIME(the most recent night flight period).
    I'm sure I've gotten close at least a few times, but I need some help getting this final formula figured out.  I really appreciate anybody's input on this.
    Date
    Flight Status
    Flight Hours
    8-1-13
    D
    2.4
    8-2-13
    N
    3.0
    8-3-13
    N
    1.1
    8-4-13
    N
    1.3
    8-5-13
    D
    2.2
    8-6-13
    N
    0.5
    8-7-13
    D
    1.1

    This may work and requires and extra column in your Data entry table (the one you provided in your post).  You can hide this new column.
    D2=IF(AND(C2>=1, B2="N"), A2, "")
    select D2 and fill down as needed.
    The table on the right is a summary table and is set up as follows:
    B2=MAX(Data :: D)
    I hope this is helpful

  • Select Most recent Occurance

    Hi Friends,
    I have a strange requirement where in we need to select the most recent occurance of a record based on 2 columns, consider the below sample data:
    C1     C2     C3
    1234     0     abc
    1234     1     abc
    1234     0     def
    1234     1     def
    1345     20     fgh
    1345     30     fgh
    1345     20     ijk
    1345     30     ijk
    now i need to write a select statement which returns the following result
    C1     C2     C3
    1234     0     def
    1234     1     def
    1345     20     ijk
    1345     30     ijk
    we need to pick data from the recent occurance of the columns C1 and C2.
    Please help me. Do let me know in case you need any thing.
    Thanks.

    Of course rowid not near always guarantees that:
    SQL> drop table t;
    Table dropped
    SQL> create table t as (
      2  select 1234 C1, 0  C2, 'abc' C3 from dual)
      3  /
    Table created
    SQL> alter table t minimize records_per_block;
    Table altered
    SQL> insert into t
      2  select  1234, 1, 'abc' from dual union all
      3  select 1234, 0, 'def' from dual union all
      4  select 1234, 1, 'def' from dual union all
      5  select 1345, 20, 'fgh' from dual union all
      6  select 1345, 30, 'fgh' from dual union all
      7  select 1345, 20, 'ijk' from dual union all
      8  select 1345, 30, 'ijk' from dual
      9  /
    7 rows inserted
    SQL> select * from t;
            C1         C2 C3
          1234          0 abc
          1345         30 ijk
          1234          1 abc
          1234          0 def
          1234          1 def
          1345         20 fgh
          1345         30 fgh
          1345         20 ijk
    8 rows selected
    SQL> select * from t where rowid in(
      2     select max(rowid) over(partition by c1,c2 order by null) from t
      3  );
            C1         C2 C3
          1234          0 def
          1234          1 def
          1345         30 fgh
          1345         20 ijk
    SQL> There is no guarantee that Oracle will insert your rows with continuously growing rowids especially if you have blocks with deleted rows, ASSM tablespaces etc. The only guarantee is to use some sequence column, because as I understand rows are inserted from flat file and therefore datetime also may be inappropriate due to the fact that rows can be inserted faster than datetime increases.
    See also this thread where a person had similar problem Row is changing position - ON INSERT
    Gints Plivna
    http://www.gplivna.eu

  • Why can't I upgrade to the most recent Firefox with a Mac 10.5.8

    I'm trying to update Firefox 3.0.10. I have a Mac 10.5.8 with 512 MB of SDRam. When I try to upgrade to the most recent Firefox it tells me my computer isn't compatible, but also tells me that Osx 10.5 with 512 MB of ram should work. Any suggestions? Is there a previous Firefox update which could work, and how would I go about finding that previous update.
    Thanks, sorry I'm not so good at this stuff.

    Firefox 3.6.x is the last available from Mozilla for PPC Macs. <br />
    http://www.mozilla.com/en-US/firefox/all-older.html
    Download Firefox 3.6.26 and install it - https://support.mozilla.com/en-US/kb/Installing+Firefox+on+Mac
    For older Macs that aren't supported in the Firefox 4+ versions, try TenFourFox for PowerPC's running Mac 10.4.11 & 10.5.8 . <br />
    http://www.floodgap.com/software/tenfourfox/<br />
    http://tenfourfox.blogspot.com/ <br />
    https://code.google.com/p/tenfourfox/wiki/PluginsNoLongerSupported <br />
    http://code.google.com/p/tenfourfox/wiki/AAATheFAQ

  • Select most recent date only

    I'm quite new to discoverer so please bear with me.
    I have a query that returns e.g. 16 records.
    One of the fields is a date field.
    What I want to do is put a condition on the date field so that it only returns the record with the most recent date.
    Thanks.

    let me explain it to u in detail
    i have the following fields
    CONTRACTNUM FIRMTYPE FIRM A FIRM B FIRM % NTP_ACTUAL
    123456 P ABC XXX 96 MM/DD/YYYY
    S XXX DEC 4 MM/DD/YYYY
    P ABC XXX 96 MM/DD/YYYY
    S XXX DEC 4 MM/DD/YYYY
    Here the CONTRACTNUM IS unique and the firm% sum is equal to 100, but the record is repeating twice , under the same CONTRACTNUM......................any suggestions willbe of great help.
    So for this i used the ROW_NUMBER() OVER(ORDER BY date_field DESC)
    in my case : ROW_NUMBER() OVER(ORDER BY ntp_actual DESC).
    Now it gives me a new field with the row_numbers and when i create a condition where the calculation is =1, it give me one record
    I was using this , because for any given contract number .............it should bring the record with the recent ntp_actual date.
    i hope i was clear.
    Thnks

  • How to make most recent messages appear at the top of the list?

    I can not find a place in Mail preferences to make my messages in each mailbox ALWAYS appear with the most recent at the top of the list. They seem to revert to the reverse order, even though I laboriously change the order in each mailbox via clicking the top of the date column. I am using primarily .Mac addresses in IMAP format, and three computers. It seems that after I shut down, then restart the next day and my computers all sycn with .Mac, the order goes back to oldest first. How can I fix this? Thanks!

    Everytime i have used webmail, the view is always retained with my previous settings. In fact the .Mac web mail help menu says the same thing (see below)
    Therefore the last thing i would recommend is to simply reset safari (which will empty the cache), delete all your Mail plist files, and not turn .Mac sync on fully until all systems are sorting consistently on their own....
    (from the .mac help menu)
    ===================
    Sorting message lists
    When you use .Mac Mail on the web, you can sort your messages, drafts, and sent messages lists by their column headers. Sorting is helpful when you want to quickly locate specific emails or groups of emails, such as all messages received from a specific sender or all flagged messages.
    To sort a message list:
    If you're not already in .Mac Mail on the web, go to www.mac.com and click Mail (at the top of the page), and log in.
    Access a message list by opening a folder.
    Click any column header to sort the list by that parameter. Clicking the same column header again reverses the order in which the list is sorted.
    When you sort a message list, all email messages in the list are sorted, not just those showing on the current page.
    Column headers vary slightly by list. The Drafts list, for example, has no From column.
    After you have sorted a list, it retains that order until you re-sort it.

Maybe you are looking for