Need to select the max record in a report

Dear All,
I have a certain report which displays the employee records along with their 'empids' and their 'beginning date'. For each 'empid', there are more than one records and hence more than one 'beginning date'. I need to select that record which contains the maximum 'beginning date'. How can this be possible in the reporting level without doing any coding in update rules or writing any exit ?
Regards,
Srinivas

Hi,
I think it is not possible because  i am having doubt how the for each employ id how it will be different joining dates,i think for each employ having differeent joining dates ,if u want to see maximum number of employs in which in company then we can go for the only option non cumulative kf with maximum value with ur joining date as the reference.but it report level if it is keyfigure we can have options of maximum and minimum and like that we can do but in case of characterstic like employnumber and joiningdate both are characterstics.
Thanks
sathsih

Similar Messages

  • Select the max record on date, but not today

    Hi all,
    I have this table
    Access
    codi_uten number(9)
    data_acce DATE
    and for
    select data_acce from Access
    the codi_uten=3041
    order by data_acce;
    this is the result
    DATA_ACCE
    29-OTT-07
    05-NOV-07
    09-NOV-07
    09-NOV-07
    09-NOV-07
    16-NOV-07
    23-NOV-07
    23-NOV-07
    20-DIC-07
    20-DIC-07
    Where 20-Dic-07 is today ;)
    I need a statment that can give me only the last data value (in this format dd/mm/yyyy) but it cannot consider today.
    It's possible without use the RowId?
    Thank's
    Paolo from Madrid

    No, you don't need rowids.
    Creating an example table:
    create table t
    ( id number primary key,
      day  date);
    insert into t values(1, sysdate);
    insert into t values(2, sysdate-1);
    insert into t values(3, sysdate-2);
    insert into t values(4, sysdate-3);Looking all rows:
    select * from t
    ID                                       DAY                 
    1                                        12/20/2007 10:24:28 A
    2                                        12/19/2007 10:24:28 A
    3                                        12/18/2007 10:24:28 A
    4                                        12/17/2007 10:24:28 A
    4 rows selectedFind the last row, except rows with day = today
    select *
    from t
    where day = (select max(day)
               from t
                 where day < trunc(sysdate))
    ID                                       DAY                 
    2                                        12/19/2007 10:24:28 AAnd, finally, formating the data
    select id, to_char(day, 'dd/mm/yyyy')
    from t
    where day = (select max(day)
               from t
                 where day < trunc(sysdate))
    ID                                       TO_CHAR(DAY,'DD/MM/YYYY')
    2                                        19/12/2007      Merry Xmas,
    Miguel

  • Select the one record with the latest record

    I have the following table called tblSales:
    SKU   TransDate   Color
    ===   ======  ====
    123   1/1/2015    Red
    123   1/2/2015    Red
    123   1/5/2015    Red
    123   1/1/2015    White
    123   1/2/2015    White
    123   1/3/2015    White
    123   1/1/2015    Blue
    123   1/2/2015    Blue
    123   1/5/2015    Blue
    I need to create a query along the lines "SELECT the latest record FROM tblSales WHERE Color = 'White''
    In this example, the record dated 1/3/2015 would be the result.  I know that MAX(TransDate) is used here, but not sure how.
    Thanks.
    Ken

    Karl,
    I had already tried that.  It returns all 3 records having SKU = 123 and Color = White.
    Worst case scenario is I can always search for White 123s using a query with TransDate DESC and then get the first record.  I was just hoping for something a bit more elegant.
    Thanks for your help though.
    Ken

  • How to select the max rowid from a subquery with group by

    Hi Gurus,
    Kindly help how to fix the following query because I'm getting Oracle error:ORA-01446.
    select * from edy_raw_data a
    where rowid in ( select max(rowid) from(
    select email,max(date_updated) from edy_raw_data b
    where b.email=a.email
    group by email ))
    The query select the max rowid from a sub query with group by.
    Thanks in Advance.
    Benjie

    Why do you need to compare with rowid?
    Wouldn't this suffice?
    select * from edy_raw_data a
    where (email,date_updated) = (select email, max(date_updated) from edy_raw_data b
                        where b.email=a.email
                        group by b.email ))* Note: untested

  • Regexp substr to select the max number out an string

    Hi all,
    I need a solution for a query.
    I,ve a query to select the lowest number in a string.
    select regexp_substr('9 - 10','\d+')
    from dual;
    9
    So this is the query I need to select the min number in he string.
    but now I need it to give me the highest nr in the string .
    the output that I need =10
    Can someone help me pleasse?
    My regards

    Caroline wrote:
    select regexp_substr('9 - 10','\d+')
    from dual;
    9
    So this is the query I need to select the min number in he string.Actually it only gives you the first number in the string, not the minimum number.
    SQL> select regexp_substr('9 - 10','\d+')
      2  from dual;
    R
    9If your string is the other way around it will give you 10 instead of 9.
    SQL> ed
    Wrote file afiedt.buf
      1  select regexp_substr('10 - 9','\d+')
      2* from dual
    SQL> /
    RE
    10You probably want something like...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select '9 - 10' as txt from dual)
      2  -- end of sample data
      3  select min(num) as min_num, max(num) as max_num
      4  from (
      5        select to_number(trim(REGEXP_SUBSTR (txt, '[^-]+', 1, level))) as num
      6        from t
      7        connect by level <= length(regexp_replace(txt,'[^-]*'))+1
      8*      )
    SQL> /
       MIN_NUM    MAX_NUM
             9         10
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select '10 - 9' as txt from dual)
      2  -- end of sample data
      3  select min(num) as min_num, max(num) as max_num
      4  from (
      5        select to_number(trim(REGEXP_SUBSTR (txt, '[^-]+', 1, level))) as num
      6        from t
      7        connect by level <= length(regexp_replace(txt,'[^-]*'))+1
      8*      )
    SQL> /
       MIN_NUM    MAX_NUM
             9         10
    SQL>

  • How to select the first record?

    Hi,
    Could anyone tell me how to select the first record of every
    group?
    ex, I want to find out every customer their first purcaseDate.
    CustomerID PurcaseDate Region
    A00000001 2001/01/01 AA
    A00000001 2001/02/02 AA
    A00000002 2001/03/01 AC
    A00000002 2001/05/07 AC
    A00000003 2001/03/05 DD
    result:
    A00000001 2001/01/01 AA
    A00000002 2001/03/01 AC
    A00000003 2001/03/05 DD
    Thanks

    Vincent,
    You could do it as Carl suggested, with a couple of
    corrections.  You would need to include the CustomNo column in
    the order by clause of your cursor.  You would also need to add
    a where clause to your update statement, otherwise everywhere
    Region in the table would be updated with the same value of the
    last CustomNo in the cursor, regardless of the CustomNo in the
    table.  See corrected code below:
    DECLARE
      CURSOR     cust
      IS
      SELECT     DISTINCT CustomNo, Region, Purchase_Date
      FROM       my_table
      ORDER BY   CustomNo, Purchase_Date, Region;
      c_customer VARCHAR2 (9) := '...';
      c_region   VARCHAR2 (2) := '..';
      cntr       NUMBER := 0;
    BEGIN
      FOR x IN cust
      LOOP
        IF x.CustomNo != c_customer
        THEN
          c_customer := x.CustomNo;
          c_region := x.Region;
        ELSE
          UPDATE my_table
          SET    Region = c_region
          WHERE  CustomNo = c_customer;
          cntr := cntr + 1;
          IF cntr = 25
          THEN
            COMMIT;
            cntr := 0;
          END IF;
        END IF;
      END LOOP;
      COMMIT;
    EXCEPTION
      WHEN OTHERS THEN 
        NULL;
    END;
    Another option is that you could just use one update statement,
    like this:
    UPDATE my_table a
    SET    Region =
           (SELECT DISTINCT Region
            FROM   my_table b
            WHERE  (CustomNo, Purchase_Date) IN
                   (SELECT   CustomNo, MIN (Purchase_Date)
                    FROM     my_table
                    GROUP BY CustomNo)
            AND    a.CustomNo = b.CustomNo)
    Barbara

  • How can I select the random records in u201Cstep loopu201D.

    Hi, Experts,
    I am using step loop to display the data on screen now I want to select the random records from this step loop display. Like 1st 3rd or 5th record, is there any way to select the records,
    like I did in Table control there was a filed in internal table named marked char length 1, I gave this field name in u201Cw/ SelColumnu201D it fill that field with u2018Xu2019 from where I can get the info about the selected records, in this way I can easily perform the operation on that internal table with the help of that marked field.
    Is there any way to select the records in step loop too ?
    Kind Regards,
    Faisal

    thanks for replay shwetali,
    but i just gave you example of random records with 1st 3rd and 5th my goal is not select only these records. i want to select the random mean any records from the step loop display.
    like we can select from the table control. and when select any record it place 'X' in the given internal table field.
    Thanks and kind Regards,
    Faisal

  • Do we need to create the mx records if the send/receive the mail in the same organization?

    1,May I know do we need to create the mx records if we send/receive the mail in the same organization?
    2,If we send /receive the mail between two different organization/forest, we need to create the mx records  ,is it right?
    Please click the Mark as Answer button if a post solves your problem!

    1,May I know do we need to create the mx records if we send/receive the mail in the same organization?
    2,If we send /receive the mail between two different organization/forest, we need to create the mx records  ,is it right?
    Please click the Mark as Answer button if a post solves your problem!
    for 1. If you mean the same Exchange org, no.
    For 2, it depends. You need a MX record for your receiving SMTP server ( At least, You *should* have one), but if sending to another org, not necessarily, as you could smarthost messages to it and a MX would not be required.
    Just curious, what problem are you trying to solve?
    Twitter!: Please Note: My Posts are provided “AS IS” without warranty of any kind, either expressed or implied.

  • Does anyone know the max record time in voice memo?

    Hi I am trying to find out what the max record time is for 1 voice memo on an i-phone 4 with 32 gb of ram.
    I can not find it documented any where.
    Thanks
    Mark

    Thanks Ingo2711,
    The pages you suggested point to the local carriers as the only authorized service centers.
    The problem with Etisalat is that they outsourced that service to another company called Technocare.
    That company sent the phone back twice (for the reasons mentioned above) and suggested that I have it fixed at a third party, which I am refusing to do since that will void my warranty. Additionally, they are refusing to give me any thing in writing to that affect.

  • I need to Delete the empty space page of report

    I need to Delete the empty space page of report 
    http://imageshack.com/a/img540/191/nrOwz6.jpg
    I Need Help!!
    Thanks

    Hi yha10,
    Per my understanding that you want to add one textbox at the bottom of the tablix and make it display as the last on each page after the tablix, you have try to add the page footer but if there is little record in the report you will got some space between
    the report footer and the last row of the tablix, right?
    If you don't want to display the space and I suggest you don't use the report footer and you can take reference to the details information below to display the information as the last row of the tablix on each page:
    Right click the Details in the Row Group and select to Add Group-->Parent Group:
    and add this expression in the Group By:
    =Ceiling(RowNumber(Nothing)/10)
    (10 is the number of rows you want to display on each page)
    Right click the row group to select the "Group Properties" and add page break by check the "Between each instance of a group":
    Right click the first column which the Group located and select the Insert Row-Inside Group-Below:
    Select the Entire Column1(Group) and delete columns:
    Merge the entire last Row and type the information "I need to show on all the page" in it:
    If you still have nay problem, please feel free to ask.
    Regards,
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • How to get the max record

    how to get the record with the max sequence no
    table as
    seq student mark
    1 A 10
    2 A 15
    1 B 20
    2 B 10
    1 C 30
    here is what i need
    seq student mark
    2 A 15
    2 B 10
    1 C 30

    i have used your query + some decode
    With t As
    Select 'A' st, 'X' Type,    1 seq,   001 marker_no, 10 mark From dual Union All
    Select 'A', 'X',    2,   001,       12 From dual Union All
    Select 'B', 'X',    1,   002,       10 From dual Union All
    Select 'B', 'X',    2,   003,       12 From dual Union All
    Select 'B', 'X',    3,   003,       15 From dual Union All
    Select 'C', 'X',    1,   001,       10 From dual Union All
    Select 'C', 'X',    2,   002,       15 From dual Union All
    Select 'C', 'Y',    3,   001,       20 From dual Union All
    Select 'C', 'Y',    4,   001,       10 From dual
    Select st,
           Sum (x_cnt) x_cnt,
           Max (x_seq) Keep (dense_rank Last Order By  x_seq) x_seq,
           max(x_marker_no) keep(dense_rank last order by x_seq) x_marker_no,
           max(x_mark) keep(dense_rank last order by x_seq) x_mark,
           sum(y_cnt) y_cnt,
           max(y_seq) keep(dense_rank last order by y_seq) y_seq,
           max(y_marker_no) keep(dense_rank last order by y_seq) y_marker_no,
           max(y_mark) keep(dense_rank last order by y_seq) y_mark
    from
        (Select st,
               decode(Type ,'X',1,0) x_cnt,
               decode(type ,'X',seq,0) x_seq,
               decode(Type ,'X',marker_no,0) x_marker_no,
               decode(Type ,'X',mark,0) x_mark,
               decode(Type ,'Y',1,0) y_cnt,
               decode(Type ,'Y',seq,0) y_seq,
               decode(Type ,'Y',marker_no,0) y_marker_no,
               decode(Type ,'Y',mark,0) y_mark
          From t
    Group By st;     
    /*this is the output
    st X_cnt X_seq X_marker_no X_mark Y_cnt Y_seq Y_marker_no Y_mark
    A  2     2     001         12     0     null  null        null
    B  3     3     003         15     0     null  null        null
    C  2     2     002         15     2     4     001         10
    ST      X_CNT      X_SEQ X_MARKER_NO     X_MARK      Y_CNT      Y_SEQ Y_MARKER_NO     Y_MARK
    A           2          2           1         12          0          0           0          0
    B           3          3           3         15          0          0           0          0
    C           2          2           2         15          2          4           1         10

  • Need to fetch the last record/row from a table

    Hi,
    I have a requirement like fetching the closing balance of the last record of the table and inserting the same into the opening balance of the immediatetly created next record.
    In simple words, I need to fetch a value from the last row of the record.
    For example, I use the below query,
    select rownum, empno, ename from emp
    where rownum = (select count(rownum) from emp);
    But, the above query does not return any of the record.
    Hence, need help on this.
    Regards,
    Shivakumar A
    Edited by: shiva on Mar 27, 2011 10:14 PM

    Rows in a table are inherently unordered. In order to introduce the concept of "first" and "last", you would need to specify how to order the rows which would require that there was one or more columns in the table that you could order by in order to determine the "last" record.
    In your closing balance example, if we assume that there is something like a BALANCE_DATE column,
    SELECT account_number, balance_amount, balance_date
      FROM (
        SELECT account_number,
               balance_amount,
               balance_date,
               rank() over (partition by account_number order by balance_date desc) rnk
          FROM table_of_balances )
    WHERE rnk = 1Justin

  • 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.

  • Selecting the last record from a database table

    In my ABAP Program, I have to use a select statement to retrieve the last record from the database table with the same key.  In other words, the Program will get more than one hit on the database table for the selected keys and I need to retrieve values from only the last record and not the first.  I know I can use an internal table to sort the records first and then retrieve the right value.   But to make things easier, is there a SELECT statement keyword than I can use to do this in one single step?  Thanks!

    hi,
    tables:mara.
        data: begin of it_mara occurs 0,
                matnr like mara-matnr,
                meins like mara-meins,
                mtart like mara-mtart,
                end of it_mara.
    select-options:s_matnr for mara-matnr.
    select matnr
              meins
              mtart
    from mara
    into table it_mara
    where matnr in s_matnr.
    if not it_mara[] is initial.
    sort it_mara by matnr descending.
    read table it_mara index 1.
    endif.
    then you get the last record of the select statement.
    reward points if useful,
    venkat.

  • How to select the next record

    Hi All,
    i have a table like below. i need the next record after the status_code = 5.
    pls help
    JOB
    job_id               prnt_job_id             status_code
    2282                 2281                        4
    2283                 2281                        4
    2284                 2281                        5
    2287                 2281                        2
    2289                 2281                        2next record after status_code = 5 is
    2287                 2281                        2

    SELECT next_job_id,
      next_prnt_job_id,
      next_status_code
    FROM
      ( WITH t1 AS
      ( SELECT 2282 job_id, 2281 prnt_job_id, 4 status_code FROM dual
      UNION ALL
      SELECT 2283, 2281, 4 FROM dual
      UNION ALL
      SELECT 2284, 2281, 5 FROM dual
      UNION ALL
      SELECT 2287, 2281, 2 FROM dual
      UNION ALL
      SELECT 2289, 2281, 2 FROM dual
    SELECT lead(job_id,1) over(order by rownum) next_job_id,
      job_id,
      lead(prnt_job_id,1) over(order by rownum) next_prnt_job_id,
      prnt_job_id,
      lead(status_code,1) over(order by rownum) next_status_code,
      status_code
    FROM t1
    WHERE status_code=5

Maybe you are looking for

  • How to Know Payment details in payment thru F110

    Dear Sir, We are using F110 for making payment to vendors against their Invoices ( MIRO Documents) . We have a following scenario . Say for a Vendor there are 2 MIRO documents against which payment thru F110 is being made and say against MIRO doc-1 

  • FRM-40200 (Not displaying the message)

    Hello Guru, I am using oracle database 11g and forms 10.0.1.2.3 version. I have a for with 2 block. One block is non data base block. Another is data base block, but query data source type is from clause query. i.e. this block is depend on a query. I

  • Cannot create pdf files anymore

    Yesterday the 19.03 I could create pdf files. An update was downloaded automatically yesterday evening and I can no longer create pdf files (as of the 20.03) I have tried creating pdf files from various applications like word, power point, outlook, e

  • Workbook Format -Template?

    Hi Guys..maybe a stupid question.. but how exactly are the workbooks used ?  Eg:  I have a company template on top, with fonts and stuff in sheet1.  Does that look replicate in all of my sheets in that workbook ?  When I try to insert another query i

  • Dynamic Analytic Privilege Concept

    HI Frzz, Could you any one give some idea about what is Dynamic Analytic Privleges and how it works. Best Regards, Krishna.