AdvancedDataGrid Summary Row Max Function

I am trying to mix summary function within an advanced data grid.   I'm trying to use the SUM function at the highest grouping level (Southwest).  And a MAX function at the sub regional level (Arizona, Central California, etc).    I want the SUM function at the Southwest level to add the results of the MAX functions from the sub regional level.   Is this possible?

You can do something like this in order to get SUM function
<!--  The grid -->
    <mx:AdvancedDataGrid  id="adg"
            width="100%" height="100%">
        <!-- Define grouping in dataProvider  -->
        <mx:dataProvider>
            <!-- Convert flat data to group  -->
            <mx:GroupingCollection  id="gc"
                    source="{svc.getOrders.lastResult}">
                <mx:Grouping>
                    <!-- First group by customer -->
                    <mx:GroupingField name="CUSTOMER">
                        <!-- Calculate total per customer  -->
                        <mx:SummaryRow summaryPlacement="group">
                            <mx:fields>
                                <mx:SummaryField dataField="PRICE"
                                                operation="SUM"
                                                label="Total"/>
                            </mx:fields>
                        </mx:SummaryRow>
                    </mx:GroupingField>
                    <!-- Then group by orderid -->
                    <mx:GroupingField name="ORDERID">
                        <!-- Calculate total per orderid  -->
                        <mx:SummaryRow summaryPlacement="group">
                            <mx:fields>
                                <mx:SummaryField dataField="PRICE"
                                                operation="SUM"
                                                label="Total"/>
                            </mx:fields>
                        </mx:SummaryRow>
                    </mx:GroupingField>
                </mx:Grouping>
            </mx:GroupingCollection>
        </mx:dataProvider>
        <!-- The grid columns-->
        <mx:columns>
            <!-- Empty colume for tree -->
            <mx:AdvancedDataGridColumn />
            <!-- Query columns -->
            <mx:AdvancedDataGridColumn  dataField="CUSTOMER"
                headerText="Customer" />
            <mx:AdvancedDataGridColumn  dataField="ORDERID"
                headerText="Order"/>
            <mx:AdvancedDataGridColumn  dataField="ARTNAME"
                headerText="Item" />
            <mx:AdvancedDataGridColumn  dataField="PRICE"
                headerText="Price" textAlign="right" />
            <!-- Column for calculated totals  -->
            <mx:AdvancedDataGridColumn  dataField="Total"
                headerText="Total" textAlign="right" />
        </mx:columns>
    </mx:AdvancedDataGrid>

Similar Messages

  • Style AdvancedDataGrid Summary Rows

    I have an AdvancedDataGrid with summary rows. Everything works fine, but the user wants the summary rows bolded, so the totals stand out even when the categories are expanded. There don't seem to be any style properties, itemRenderers, or labelFunctions associated with any level of a GroupingCollection. How can I do this?
    Thanks.
    -John

    I figured it out, so here it is for posterity:
    I had to use the AdvancedDataGridColumn's styleFunction, and test the row object for a "GroupLabel" property. If it exists, bold the row, like below:
              protected function boldSummaryRows(row:Object, column:AdvancedDataGridColumn):Object {
                    var styleObject:Object = new Object;
                    if(row.hasOwnProperty('GroupLabel'))
                        styleObject.fontWeight = 'bold';
                    return styleObject;

  • AdvancedDatagrid with a summary row

    Hello,
    I have an AdvancedDatagrid with two grouping fields in a
    summary row.
    Everything works fine when there is no labelFunction
    associated with it.
    But as soon as I specify a labelFunction, the summary row
    fields are empty. I need a labelFunction to format dates and
    numbers.
    How to write a proper labelFunction for an AdvancedDatagrid
    with a summary row ?
    Regards,
    Karl.

    Okay, I figured it out.
    Now, I have two label functions set at the
    AdvancedDataGridColumn level for the summary row fields and one
    labelFunction set at the AdvancedDataGrid level for all the other
    fields.
    <mx:AdvancedDataGridColumn id="amountTotal"
    dataField="sumAmount" labelFunction="sumAmountLabelFunction" />
    <mx:AdvancedDataGridColumn id="collectedTotal"
    dataField="sumCollected" labelFunction="sumCollectedLabelFunction"
    />
    In order to avoid a null pointer exception on the sumAmount
    and sumCollected fields in the label function, I use the
    hasOwnProperty() method to check before access. Otherwise, this
    exception will happen while expanding the tree.
    private function sumAmountLabelFunction(item:Object,
    column:AdvancedDataGridColumn):String
    if(item.hasOwnProperty("sumAmount"))
    return this.numberFormatter.format(item.sumAmount);
    return "";
    private function sumCollectedLabelFunction(item:Object,
    column:AdvancedDataGridColumn):String
    if(item.hasOwnProperty("sumCollected"))
    return this.numberFormatter.format(item.sumCollected);
    return "";

  • Using Previous function in summary rows?

    Hi,
    I have a requirment, where I have to use the value got in previous column in the summary row.
    The scenario is as follows.
    There are Product, Quantity on Hand , Order Type and Date column. I am using cross tab, As I have to use the details of columns for each date.
    So date will be spreaded across table as there are more dates.
    In summary column, I would like to do a calcuation for each date. And I should use the calculated amount on one date in the next date and the calcuation continues.
    I am trying to use previous function, but its showing computation error.
    I am attaching a excel sheet with a sample example for easy understanding.
    The calculation which I used in summary row is avialble in formula section, when we select the column.
    Thanks in Advance.
    Regards
    Gowtham

    Hi BOCP,
    Yes, I am trying to use this function in Summary after Break.
    Sorry, I missed out attachment. And I didn't find a way to attach it.
    Suresh,
    I didn't find last() function in WebI Editor. I am using BO XI R2.
    Thanks a lot.
    Regards,
    Gowtham Sen.

  • Max function for table having no rows

    Hi All
    I have a table in which initially no rows. I am running max() function for a column and then wnats to add 1.
    But when no rows there below code in not working
    select max(code) into p_maxCode from cms_codedetails where codetypeid=0;
    p_maxCode:=p_maxCode+1;
    dbms_output.PUT_LINE('p_maxCode: '||p_maxCode);
    result is:
    p_maxCode:
    How can I handle the this to get 1 if no rows in the table .

    Hi !
    Max function in yur case returns NULL and then
    null + <anything> ... is still null
    You can do
    p_maxCode:=nvl(p_maxCode,0)+1;
    or
    select nvl(max(code),0) into p_maxCode from cms_codedetails where codetypeid=0;
    Of course if YOU have decide that null in this case can be treated as 0
    T

  • Customizing summary row AdvancedDatagrid

    i want to customise the look and feel of the summaryRow of the AdvancedDatagrid by including borders to the top and the bottom.I tried overriding createChildren() and adding HRule  as the first and last child of the summaryRenderer.The HRule is  getting added but it is not getting displayed.Am i doing somthing wrong.If so how can i customize the look and feel .Please suggest

    You can just use Renderer providers to customize your SummaryRow just like you use Renderer Providers for your columns.Specify the label name of the summary row that you want to customize in the renderer provider.

  • Summary rows

    I am new to Flex. I wasn't quite sure how to code summary
    rows in actionscript. Could some take a look at my codes and help
    me figure out why it doesn't work? I really appreciate it.
    I need to display a fixed data in group row. That is, I don't
    need to calculate the result to be displayed in group row.

    "irislpc" <[email protected]> wrote in
    message
    news:ghpdmn$s2k$[email protected]..
    > If I am not displaying the hierarchical data in
    AdvancedDataGrid by using
    > group
    > collection, can I still use summary rows? I populate the
    advanced data
    > grid
    > with external xml file. The xml is structured
    hierarchically so that I
    > don't
    > need to group the data. The problem is I have data that
    need to be
    > displayed in
    > group row. Can I use summaries function to do that?
    > Here is the sample application
    >
    http://www.irislin.net/itemRenderer/reliability.html
    http://livedocs.adobe.com/flex/3/html/help.html?content=advdatagrid_08.html
    "Note: Summary data is not supported for hierarchical data
    represented by
    the HierarchicalData class. You can only create summary data
    for data
    represented by the GroupingCollection class."
    I couldn't get at your app, since I'm not going to upgrade to
    Flash Player
    10 just to help you (I think that change is far more
    difficult to undo than
    to do), but you might find that you can make a
    GroupingCollection from your
    XML just by casting it.

  • String type data in Summary Row

    Hi,
    Can any one hlep out on this..
    I am working as a flex developer in one organization.I have a special scenario like,
    I want to display comments in Summary Row,
    But as per my knowledge Summary Rows can hold only numeric data.is it possible to display String type data in Summary row.
    If possible , please provide that piece of code.

    "nikos101" <[email protected]> wrote in
    message
    news:gq8693$9a$[email protected]..
    >I am using the following in a summary row in a
    AdvancedDataGrid. How would
    >I
    > modify it to also display a piechart with its data?
    >
    > package
    > {
    > import
    mx.controls.advancedDataGridClasses.AdvancedDataGridItemRenderer;
    > import mx.controls.listClasses.BaseListData;
    >
    > public class ItemTotalGBP_Renderer extends
    AdvancedDataGridItemRenderer
    > {
    > public function ItemTotalGBP_Renderer()
    > {
    > super();
    > }
    >
    > override public function set data(value:Object):void
    > {
    > super.data = value;
    > listData.label = " " + data["totalTransfers"]
    > +
    > " Transfers " + data["totalGBP_Eq"].toFixed(2) + " GBP
    equivalent";
    > }
    >
    > }
    > }
    The pie chart example here seems really close to what you
    want:
    http://www.adobe.com/livedocs/flex/3/html/help.html?content=advdatagrid_10.html

  • MAX function

    Hi Everyone,
    Am aware of the following flavors of MAX function
    1) choose MAX from the folders/fields list (selected items tab)
    2) create calculation using: MAX keep dense
    3) create calculation using: MAX analytic function
    questions, pls:
    ===========
    a) with MAX regular, MAX keep dense, MAX - analytic function
    is it necessary to sort it using tools/sort - choose fields to sort by?
    or does the data get sorted due to the ORDER BY clause in MAX used in a calculation
    b) how to understand the diff. bet. MAX keep dense and MAX - analytic function
    1) i understand that analytic functions are applied after detail row processing
    does MAX keep dense calculation happen during detail row processing?
    2) how did you know to advise when to use MAX keep dense, and when to use MAX - analytic function?
    tx for your ideas and assistance, sandra

    Hi,
    a) with MAX regular, MAX keep dense, MAX - analytic function is it necessary to sort it using tools/sort - choose fields to sort by? or does the data get sorted due to the ORDER BY clause in MAX used in a calculationIt is only necessary to use a sort if you want to have the rows returned in a specific order. The order by in the max calculation defines the maximum within the group or window. It may affect the order the rows are returned, but if it does this is not guaranteed and you should use a sort on the main query.
    b) how to understand the diff. bet. MAX keep dense and MAX - analytic function
    1) i understand that analytic functions are applied after detail row processing does MAX keep dense calculation happen during detail row processing?Yes
    2) how did you know to advise when to use MAX keep dense, and when to use MAX - analytic function?In general, if you want the result on a single row, so you have one row for each group then you should use the aggregate max. If you want to use the same max on all the rows in the window (defined by the partition) then use the analytic max.
    Rod West

  • Using max function in PL/SQL

    VERY URGENT...
    Am new to oracle...
    I've written a package that display gif images in form of histogram/bar chart. using html,
    I need to use max function to display values proportionately.
    please help. i need to complete this assignment by 2/9/00 by 10.00 am at the latest. I've half written a function but I don't know if there's a simpler way fo doing this. html enabled

    First of all Thanks to all gentlemen who replied ..many thanks ...
    Tried the ROW_NUMBER() option but still it is taking time...have given output for the query and tkprof results as well. Even when it doesn't fetch any record ( this is a valid cased because the input header id doesn't have any workflow request submitted & hence no entry in the wf_items table)..then also see the time it has taken.
    Looked at the RANK & DENSE_RANK options which were suggested..but it is still taking time..
    Any further suggestions or ideas as to how this could be resolved..
    SELECT 'Y', 'Y', ITEM_KEY
    FROM
    ( SELECT ITEM_KEY, ROW_NUMBER() OVER(ORDER BY BEGIN_DATE DESC) RN FROM
    WF_ITEMS WHERE ITEM_TYPE = 'xxxxzzzz' AND ROOT_ACTIVITY = 'START_REQUESTS'
    AND SUBSTR(ITEM_KEY,1,INSTR(ITEM_KEY,'-') - 1) = :B1
    ) T WHERE RN <= 1
    call count cpu elapsed disk query current rows
    Parse 0 0.00 0.00 0 0 0 0
    Execute 1 0.00 1.57 0 0 0 0
    Fetch 1 8700.00 544968.73 8180 8185 0 0
    total 2 8700.00 544970.30 8180 8185 0 0
    many thanks

  • Use COUNT or MAX functions inside of a query, and you have no data found

    I'm writing a query with a COUNT and a MAX function.
        SELECT  li.id
                 , MAX(m.display_date)
                , COUNT(*)
         FROM li JOIN m  ON (m.LIID=li.LIID)
        WHERE m.DISPLAY_DATE < SYSDATE - 7
        GROUP BY  li.id;I would like to write a query that returns always a row foe each row in the table li.
    If there are no records with the condition "WHERE m.DISPLAY_DATE < SYSDATE - 7", I would like to have a row with
    - COUNT(*) = 0
    - MAX(m.display_date) = TO_DATE('2010-06-08', 'YYYY-MM-DD'

    user600979 wrote:
    I'm writing a query with a COUNT and a MAX function.
    SELECT  li.id
    , MAX(m.display_date)
    , COUNT(*)
    FROM li JOIN m  ON (m.LIID=li.LIID)
    WHERE m.DISPLAY_DATE < SYSDATE - 7
    GROUP BY  li.id;I would like to write a query that returns always a row foe each row in the table li.
    If there are no records with the condition "WHERE m.DISPLAY_DATE < SYSDATE - 7", I would like to have a row with
    - COUNT(*) = 0
    - MAX(m.display_date) = TO_DATE('2010-06-08', 'YYYY-MM-DD'In that case tell me what do you want to display in the ID column. That is the first column?

  • Using Max Function in View Criteria

    Hi
    I am having a requirement where by i need to make use of max function in view criteria but not able to see any such option. Can someone please help me over it. Here is the requirement.
    In table i will be having multiple rows for an employee and i need to pick latest row based on a column say request_id For e.g.
    Emp RequestId
    A 1
    A 2
    A 3
    A 4
    So if i pass the employee id i should get Row Number 4. In simple SQL language I want something like this
    select * from emp where empid=A and requestid=( select max(requestid) from emp where empid=A)
    Just wanted to know is there any approach that i can use to do all this as part of View Criteria or any other way.
    Any help is appreciated!!!
    Thanks
    AJ

    One way is this -
    1)https://blogs.oracle.com/adf/entry/using_groovy_aggregate_functions_in (You might need to create a self-referencing VL for this , try if it works using a ViewAccessor too)
    OR
    Order by RequestId descending in your SQL for the VO if thats ok , then have the ViewCriteria for the EmpId and programmatically pickup the first row...

  • Improve built in SQL MAX function

    Hi
    I am trying to improve the performance of the built in SQL max function. right now searching through over 500,000 rows takes lot of time which can be reduced. Can anyone suggest me something which would be helpful in this or may be give me a link if it has been discussed before?
    Anything is appreciated.
    Thanks

    Tolls wrote:
    Um...considering you were planning on improving on the MAX function, I sort of thought you might actually know how to use it. Otherwise how would you know it was running slowly?thanks Tolls i'd figured it out right after i posted it. i guess i was too excited after reading (you got it in milliseconds) that posted right away without doing anything myself..but yeah it did make it super fast..thanks a lot for your help and time..
    cotton.m wrote:
    d_khakh wrote:
    hi tolls thanks for getting back
    could u explain how did u do that? i found out how to create index..i have the following statement:
    create index col on table2 (col2);
    cud u tell me how to go from here and find the max in col2..thanks again for ur help?
    sigh
    Where to go from here? Just execute your damn query. If you really did create the index on the right column and your database isn't stupid and there isn't a lot more to this problem then you told us about like some where clauses then that's it. She's as fast as she's going to get.
    And remember, it's impolite to converse in a public forum while chewing your cud. Unless of course you actually meant "could" but were just too lazy to type it. Don't be lazy, use full words. Thanks.like i said above..i figured it out after some time.
    i wasn't being lazy ..thats msn talk..i thought people understood that..anyways your point noted too.

  • Usage of MAX Function.

    Hi,
    One of our customers is facing an error while executing a PL/SQL block like,
    declare
    l_flag varchar2(30);
    begin
    select max('Y') into l_flag from v$database; -- Can use any table here
    end;
    however, when the select query is changed to as follows, no error is seen.
    select substr(max('Y'),1,30) into l_flag from v$database;
    Can someone please help me in identifying what could be issue?
    Thanks,
    Dola

    We are actually trying to check if the table contains any rows.Hmmm, I would have thought that using a MAX() function to do that is rather expensive (if it's a large table)...
    SQL> set autotrace traceonly stat
    SQL> select max('Y') from tt1
      2  /
    Statistics
              0  recursive calls
              0  db block gets
            432  consistent gets
            428  physical reads
              0  redo size
            378  bytes sent via SQL*Net to client
            499  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL>          
    SQL> select count(*) from tt1
      2  /
    Statistics
              0  recursive calls
              0  db block gets
            432  consistent gets
            423  physical reads
              0  redo size
            381  bytes sent via SQL*Net to client
            499  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL>          
    SQL> select null  from tt1
      2  where rownum = 1
      3  /
    Statistics
              0  recursive calls
              0  db block gets
              4  consistent gets
              5  physical reads
              0  redo size
            372  bytes sent via SQL*Net to client
            499  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL> Cheers, APC

  • MAX Function not returning MAX

    I have a query that is pulling in EDI 214 status codes, and want to pull in the last received status for status type "AG". To do this, I'm using the MAX function on the INSERT_DATE field of the status code AG, but the query keeps returning both AG status codes. I've tried this in a single query (Query 1) but it did not work so I also attempted it in a much smaller query to be used as a subquery, but that still did not work. Can anyone identify what the issue is with what I'm attempting to do?
    Query 1 (All Inclusive):
    SELECT BS.SHIPMENT_GID AS BUY_SHIPMENT_GID,
    AGSS.EVENTDATE AS AG_EVENT,
    D1SS.EVENTDATE AS D1_EVENT,
    BS.START_TIME AS BUY_START_TIME,
    AGSS.STATUS_CODE_GID AS AG,
    D1SS.STATUS_CODE_GID AS D1,
    BS.DOMAIN_NAME AS BUY_DOMAIN,
    MAX(AGSS.INSERT_DATE) AS AG_INSERT_DATE,
    MAX(D1SS.INSERT_DATE) AS D1_INSERT_DATE,
    BS.START_TIME,
    BS.DOMAIN_NAME,
    SHIPSTAT.STATUS_VALUE_GID
    FROM V_ROD_SHIPMENT BS
    INNER JOIN V_ROD_SS_STATUS_HISTORY AGSH
    ON (BS.SHIPMENT_GID = AGSH.SHIPMENT_GID)
    INNER JOIN V_ROD_IE_SHIPMENTSTATUS AGSS
    ON (AGSH.I_TRANSACTION_NO = AGSS.I_TRANSACTION_NO)
    INNER JOIN V_ROD_SS_STATUS_HISTORY D1SH
    ON (BS.SHIPMENT_GID = D1SH.SHIPMENT_GID)
    INNER JOIN V_ROD_SHIPMENT_STATUS SHIPSTAT
    ON (BS.SHIPMENT_GID = SHIPSTAT.SHIPMENT_GID)
    INNER JOIN V_ROD_IE_SHIPMENTSTATUS D1SS
    ON D1SH.I_TRANSACTION_NO = D1SS.I_TRANSACTION_NO
    WHERE BS.START_TIME > '18/MAY/12'
    AND BS.DOMAIN_NAME = 'UPS/CP/HDMB'
    AND AGSS.STATUS_CODE_GID = 'AG'
    AND D1SS.STATUS_CODE_GID = 'D1'
    AND (SHIPSTAT.STATUS_VALUE_GID = BS.DOMAIN_NAME
    || '.SECURE RESOURCES_ACCEPTED'
    OR SHIPSTAT.STATUS_VALUE_GID = BS.DOMAIN_NAME
    || '.SECURE RESOURCES_PICKUP NOTIFICATION')
    GROUP BY BS.SHIPMENT_GID,
    AGSS.EVENTDATE,
    D1SS.EVENTDATE,
    BS.START_TIME,
    AGSS.STATUS_CODE_GID,
    D1SS.STATUS_CODE_GID,
    BS.DOMAIN_NAME,
    SHIPSTAT.STATUS_VALUE_GID
    Query 2 (to be used as a sub-query if I cannot pull MAX insert date in previous query):
    SELECT DISTINCT BS.SHIPMENT_GID AS BUY_SHIPMENT_GID,
    AGSS.EVENTDATE AS AG_EVENT,
    AGSS.STATUS_CODE_GID AS AG,
    MAX(AGSS.INSERT_DATE) AS AG_INSERT_DATE
    FROM V_ROD_SHIPMENT BS
    INNER JOIN V_ROD_SS_STATUS_HISTORY AGSH
    ON (BS.SHIPMENT_GID = AGSH.SHIPMENT_GID)
    INNER JOIN V_ROD_IE_SHIPMENTSTATUS AGSS
    ON (AGSH.I_TRANSACTION_NO = AGSS.I_TRANSACTION_NO)
    WHERE AGSS.STATUS_CODE_GID = 'AG'
    AND BS.SHIPMENT_GID = 'UPS/CP/HDMB.HDM-1000203768'
    GROUP BY BS.SHIPMENT_GID,
    AGSS.EVENTDATE,
    AGSS.STATUS_CODE_GID
    Results of query 2 (similar issue as query 1, query doesn't return MAX insert date):
    BUY_SHIPMENT_GID     AG_EVENT     AG     AG_INSERT_DATE
    UPS/CP/HDMB.HDM-1000203768     5/25/2012 6:00:00 PM     AG     5/21/2012 3:10:36 PM
    UPS/CP/HDMB.HDM-1000203768     6/1/2012 5:00:00 PM     AG     5/20/2012 2:36:18 PM
    I appreciate any help.
    Thanks,
    -Adam

    Hi, Adam,
    Welcome to the forum!
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    Simplify the problem as much as possible. Remove all tables and columns that play no role in this problem.
    If you can show what the problem is using commonly available tables (such as those in the scott schem) then you don't have to psot any sample data; just the results and the explanation.
    Always say which version of Oracle you're using.
    See the forum FAQ {message:id=9360002}
    MAX (insert_date) returns the latest insert_date. I think, in this problem, you don't really want the latest insert_date; you want the status code that's related to the last insert_date. One way to get that is the aggregate FIRST (or LAST) function.
    Consider this query, using the scott.emp table:
    SELECT       ename
    ,       hiredate
    FROM       scott.emp
    ORDER BY  hiredate
    ,            ename
    ;Output:
    ENAME      HIREDATE
    SMITH      17-Dec-1980
    ALLEN      20-Feb-1981
    WARD       22-Feb-1981
    JONES      02-Apr-1981
    BLAKE      01-May-1981
    CLARK      09-Jun-1981
    TURNER     08-Sep-1981
    MARTIN     28-Sep-1981
    KING       17-Nov-1981
    FORD       03-Dec-1981
    JAMES      03-Dec-1981
    MILLER     23-Jan-1982
    SCOTT      19-Apr-1987
    ADAMS      23-May-1987Say we're only interested in seeing the last hiredate, and the name of the person hired on that date:
    LAST_ENAME LAST_HIREDA
    ADAMS      23-May-1987Here's how to get those results using the aggregate LAST function:
    SELECT       MIN (ename) KEEP (DENSE_RANK LAST ORDER BY hiredate) AS last_ename
    ,       MAX (hiredate)                                              AS last_hiredate
    FROM       scott.emp
    ;What if there's a tie for the latest hiredate? For example, say we're only looking at people hired before 1982. In that case, the latest hiredate is December 3, 1981, and there happen to be two people hired on that date. This query
    SELECT       MIN (ename) KEEP (DENSE_RANK LAST ORDER BY hiredate) AS last_ename
    ,       MAX (hiredate)                                              AS last_hiredate
    FROM       scott.emp
    WHERE         hiredate     < DATE '1982-01-01'
    ;produces only 1 row of output:
    LAST_ENAME LAST_HIREDA
    FORD       03-Dec-1981Why did it show FORD rather than JAMES? Because of the MIN function. When there happens to be a tie for the latest hiredate, MIN says to return the first ename (in normal sort order) of the rows that have that hiredate.
    FIRST and LAST work with GROUP BY, too.
    In the example above, we were only looking at one column related to the latest hiredate. If we neede to see several columns, it would be simpler to use the analytic ROW_NUMBER function:
    WITH     got_r_num     AS
         SELECT  emp.*
         ,     ROW_NUMBER () OVER ( ORDER BY  hiredate  DESC
                                   ,            ename
                           ) AS r_num
         FROM    scott.emp
         WHERE     hiredate     < DATE '1982-01-01'
    SELECT     *
    FROM     got_r_num
    WHERE     r_num     = 1
    I hope this answers your question.
    If not, post a more complete explanation of what you want to do. if you have to use your own tables, then post CREATE TABLE and INSERT statements for a little sample data. Post the results you want from that data, and explain how you get those results from that data.

Maybe you are looking for

  • Wifi Locking in but nothing happening

    First off I love the Itouch! Second I am just a little frustrated because I cannot seem to get the wifi to work in my itouch away from my home. I lock into a wifi hotspot yet I cannot get my weather apps or stock apps updated. I get full bars and I h

  • Worth installing compared to 10.1.3?

    Hi there, We've installed ZCM 10.1.3 and the ZCM database on a separate SLES box. We've upgraded the single Primary server to 10.2. Is it worth scrapping the "old" database server and installing 10.2 Reporting Server? We haven't done much configurati

  • Itunes quit unexpectedly after installing osx leopard

    I have just installed OSX Leopard and now itunes 7.5 refuses its service. i have re-installed it several times, deleted all plists and database files. i also removed the whole itunes folder from my music folder and re-installed itunes hoping that i c

  • T61: "Error loading operating system" after reboot with Windows XP SR3

    So here is my problem:  Occasionally, after reboot I get "Error loading operating system" right after the Lenovo screen (the one where you can press ThinkVantage button). After that the only thing I can do is shut down the computer and fix the window

  • Financial Report Backup

    Hi, Please guide me how to take Financial Report (11.1.1.3) Backup? Thank You EP