Minimum & Maximum dates in a group of records

I have a set of records in which contains following fields, i have to present a report showing
Product, Quality produced on which machine, Start Date & End Date, how this task may be performed ?
Sample report is in the end for ref.
pls help.
MACHINE PROD QUALITY TRAN_DATE
CODE CODE
1002     101     2     15/11/2011
1002     101     2     16/11/2011
1002     101     2     17/11/2011
1002     101     2     18/11/2011
1002     101     2     19/11/2011
1002     101     2     20/11/2011
1002     101     1     21/11/2011
1002     101     1     22/11/2011
1002     101     1     23/11/2011
1002     101     1     24/11/2011
1002     101     1     25/11/2011
1002     101     2     26/11/2011
1002     101     2     27/11/2011
1002     101     2     28/11/2011
1002     101     2     29/11/2011
1002     101     2     30/11/2011
Product Quality Machine Start Date End Date
101 2 1002 15/11/2011 20/11/2011
101 1 1002 21/11/2011 25/11/2011
101 2 1002 26/11/2011 25/12/2011

Sir,
Thanks for the suggestion, but when I run this query for multiple machine codes, it is not generating desired output, what changes I have to make to get desired output, I have arranged the data in format desired by you..
with t_data as
select 1001 machine_code,     105 prod_code,     2     quality, to_date('01/12/2011','DD/MM/YYYY') tran_date from dual union all
select 1001,     105,     2,     to_date('02/12/2011','DD/MM/YYYY') tran_date from dual union all
select 1001,     105,     2,     to_date('03/12/2011','DD/MM/YYYY') tran_date from dual union all
select 1001,     105,     2,     to_date('04/12/2011','DD/MM/YYYY') tran_date from dual union all
select 1001,     105,     2,     to_date('05/12/2011','DD/MM/YYYY') tran_date from dual union all
select 1001,     105,     2,     to_date('06/12/2011','DD/MM/YYYY') tran_date from dual union all
select 1001,     105,     2,     to_date('07/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105,     2,     to_date('08/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105,     2,     to_date('09/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105,     2,     to_date('10/12/2011','DD/MM/YYYY') tran_date from dual union all
select 1001,     105,     2,     to_date('11/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105,     2,     to_date('12/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105,     2,     to_date('13/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105,     2,     to_date('14/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105,     2,     to_date('15/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105,     2,     to_date('16/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105,     2,     to_date('17/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105,     2,     to_date('18/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105,     2,     to_date('19/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105,     2,     to_date('20/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105,     2,     to_date('21/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105,     2,     to_date('22/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105,     2,     to_date('23/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105,     2,     to_date('24/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1001,     105, 2,     to_date('25/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     101,     2,     to_date('01/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     101,     2,     to_date('02/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     101,     2,     to_date('03/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     101,     2,     to_date('04/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     101,     2,     to_date('05/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     101,     2,     to_date('06/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     101,     2,     to_date('07/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     101,     2,     to_date('08/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     101,     2,     to_date('09/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     101,     2,     to_date('10/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     101,     2,     to_date('11/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     101,     2,     to_date('12/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     101,     2,     to_date('13/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     101,     2,     to_date('14/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     109,     1,     to_date('15/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     109,     1,     to_date('16/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     109,     1,     to_date('17/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     109,     1,     to_date('18/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     109,     1,     to_date('19/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     109,     1,     to_date('20/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     109,     1,     to_date('21/12/2011','DD/MM/YYYY') tran_date from dual union all
select 1002,     109,     1,     to_date('22/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     109,     1,     to_date('23/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     101,     2,     to_date('24/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1002,     101,     2,     to_date('25/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('01/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('02/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('03/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('04/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('05/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('06/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('07/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('08/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('09/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('10/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('11/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('12/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('13/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('14/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('15/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('16/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('17/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('18/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('19/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('20/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('21/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('22/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('23/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('24/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1003,     101,     1,     to_date('25/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('01/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('02/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('03/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('04/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('05/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('06/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('07/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('08/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('09/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('10/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('11/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('12/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('13/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('14/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('15/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('16/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('17/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('18/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('19/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('20/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('21/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('22/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('23/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('24/12/2011','DD/MM/YYYY') tran_date from dual union all
select     1004,     101,     2,     to_date('25/12/2011','DD/MM/YYYY') tran_date from dual
SELECT
PROD_CODE,
QUALITY,
MACHINE_CODE,
MIN(TRAN_DATE),
MAX(TRAN_DATE)
FROM
SELECT
t.*,
row_number() over(order by TRAN_DATE) -
row_number() over(partition BY MACHINE_CODE,PROD_CODE,QUALITY order by TRAN_DATE) AS dt
FROM
t_data t
GROUP BY
MACHINE_CODE,PROD_CODE,QUALITY,dt;

Similar Messages

  • Need a maximum date value using group by

    Create table student (dept number(10), dep_name varchar2(10),join_date date,years_attended number(10),end_date date);
    insert into student values (1,'I',to_date('3/7/1917','MM/DD/YYYY'),4,to_date('8/26/1987','MM/DD/YYYY'));
    insert into student values (1,'I',to_date('1/1/1900','MM/DD/YYYY'),4,to_date('8/26/1932','MM/DD/YYYY'));
    insert into student values (1,'D',to_date('1/1/1920','MM/DD/YYYY'),5,to_date('8/26/1994','MM/DD/YYYY'));
    insert into student values (1,'C',to_date('1/1/1920','MM/DD/YYYY'),6,to_date('8/26/1945','MM/DD/YYYY'));
    insert into student values (2,'I',to_date('7/1/1900','MM/DD/YYYY'),3,to_date('8/26/1932','MM/DD/YYYY'));
    insert into student values (2,'I',to_date('8/16/1916','MM/DD/YYYY'),9,to_date('8/26/1923','MM/DD/YYYY'));
    insert into student values (2,'D',to_date('8/16/1916','MM/DD/YYYY'),10,to_date('8/26/1987','MM/DD/YYYY'));
    insert into student values (3,'I',to_date('3/7/1917','MM/DD/YYYY'),4,to_date('8/26/1987','MM/DD/YYYY'));
    insert into student values (3,'D',to_date('7/28/1920','MM/DD/YYYY'),6,to_date('8/26/1945','MM/DD/YYYY'));
    insert into student values (3,'I',to_date('7/28/1920','MM/DD/YYYY'),8,to_date('8/26/1965','MM/DD/YYYY'));
    insert into student values (4,'I',to_date('12/31/1924','MM/DD/YYYY'),2,to_date('8/26/1998','MM/DD/YYYY'));
    insert into student values (4,'I',to_date('6/10/1929','MM/DD/YYYY'),1,to_date('8/26/1943','MM/DD/YYYY'));
    insert into student values (4,'C',to_date('1/17/1927','MM/DD/YYYY'),4,to_date('8/26/1955','MM/DD/YYYY'));
    insert into student values (4,'C',to_date('6/10/1929','MM/DD/YYYY'),30,to_date('8/26/1967','MM/DD/YYYY'));
    insert into student values (5,'D',to_date('2/10/1931','MM/DD/YYYY'),2,to_date('8/26/1943','MM/DD/YYYY'));
    insert into student values (5,'I',to_date('2/10/1931','MM/DD/YYYY'),24,to_date('8/26/1962','MM/DD/YYYY'));
    commit;I need a maximum date value join_date for each department. If max(join_date) has two records for each dept then max(end_date) should be considered. I have used a below select query
    select * from student where join_date in (select
    max(join_date) from student group by dept);which gives me the following result
    1     D     1/1/1920     5     8/26/1994
    1     C     1/1/1920     6     8/26/1945
    2     I     8/16/1916     9     8/26/1923
    2     D     8/16/1916     10     8/26/1987
    3     D     7/28/1920     6     8/26/1945
    3     I     7/28/1920     8     8/26/1965
    4     I     6/10/1929     1     8/26/1943
    4     C     6/10/1929     30     8/26/1967
    5     D     2/10/1931     2     8/26/1943
    5     I     2/10/1931     24     8/26/1962But I am looking for the result which gives me only one maximum value for each dept column. First it should look for maximum value of join_date, if two records has same join_date then max(end_date) should be considered. The result should be sumthing like this
    1     D     1/1/1920     5     8/26/1994
    2     D     8/16/1916     10     8/26/1987
    3     I     7/28/1920     8     8/26/1965
    4     C     6/10/1929     30     8/26/1967
    5     I     2/10/1931     24     8/26/1962Can you please tell me how to rewrite the select query to get the above results.
    Edited by: user11872870 on Aug 2, 2011 5:29 PM
    Edited by: user11872870 on Aug 2, 2011 5:36 PM

    Hi,
    That's called a Top-N Query , and here's one way to do it:
    WITH     got_r_num     AS
         SELECT     student.*
         ,     ROW_NUMBER () OVER ( PARTITION BY  dept
                                   ORDER BY          join_date     DESC
                             ,                end_date     DESC
                           )      AS r_num
         FROM    student
    SELECT       dept, dep_name, join_date, years_attended, end_date
    FROM       got_r_num
    WHERE       r_num     = 1
    ORDER BY  dept
    ;Another way is similar to what you originally posted:
    SELECT    *
    FROM       student
    WHERE        (dept, join_date, end_date)
                   IN (
                        SELECT    dept
                   ,       MAX (join_date)
                   ,       MAX (end_date) KEEP (DENSE_RANK LAST ORDER BY join_date)
                   FROM      student
                   GROUP BY     dept
                   );I suspect the first way (using ROW_NUMBER) will be faster.
    Also, the ROW_NUMBER approach is guaranteed to return only 1 row per dept. Using the GROUP BY approach,if there is a tie on join_date and end_date, then it will return all contenders in that dept. Using ROW_NUMBER, it's easy to add as many tie-breaking expressions as you want, and, if there is still a tie, it will arbirarily pick one of the rows involved in the tie as #1.
    Thanks for posting the CREATE TABLE and INSERT statments! That's very helpful.
    Edited by: Frank Kulash on Aug 2, 2011 9:00 PM
    Added GROUP BY alternative

  • Split the incoming data into multiple grouped output records

    I have three fields in the source, Student ID, Student name and Student Marks. I need to map the details in the destination, by grouping the data on the basis of marks obtained. Each time there's a new mark , the corresponding details of names and student
    ID is saved under the a new mark group that is created. how do i come about it when there are n number of new marks?

    for your scenario i used below xml as input,
    <ns0:Students xmlns:ns0="http://BTSTempProj.StudentDetailsIn">
      <Student>
        <StudentID>StudentID_0</StudentID>
        <StudnetName>StudnetName_0</StudnetName>
        <StudentMarks>10</StudentMarks>
      </Student>
      <Student>
        <StudentID>StudentID_0</StudentID>
        <StudnetName>StudnetName_0</StudnetName>
        <StudentMarks>20</StudentMarks>
      </Student>
      <Student>
        <StudentID>StudentID_0</StudentID>
        <StudnetName>StudnetName_0</StudnetName>
        <StudentMarks>10</StudentMarks>
      </Student> 
      <Student>
        <StudentID>StudentID_0</StudentID>
        <StudnetName>StudnetName_0</StudnetName>
        <StudentMarks>10</StudentMarks>
      </Student>
      <Student>
        <StudentID>StudentID_0</StudentID>
        <StudnetName>StudnetName_0</StudnetName>
        <StudentMarks>20</StudentMarks>
      </Student>
      <Student>
        <StudentID>StudentID_0</StudentID>
        <StudnetName>StudnetName_0</StudnetName>
        <StudentMarks>30</StudentMarks>
      </Student>   
    </ns0:Students>
    and here is the output, hope this is what you are looking for. 
    <ns0:Students xmlns:ns0="http://BTSTempProj.StudentDetailsOut">
    <StudentMarks>10</StudentMarks>
    <Student>
    <StudentName>StudnetName_0</StudentName>
    <StudentID>StudentID_0</StudentID>
    <StudentName>StudnetName_0</StudentName>
    <StudentID>StudentID_0</StudentID>
    <StudentName>StudnetName_0</StudentName>
    <StudentID>StudentID_0</StudentID>
    </Student>
    <StudentMarks>20</StudentMarks>
    <Student>
    <StudentName>StudnetName_0</StudentName>
    <StudentID>StudentID_0</StudentID>
    <StudentName>StudnetName_0</StudentName>
    <StudentID>StudentID_0</StudentID>
    </Student>
    <StudentMarks>30</StudentMarks>
    <Student>
    <StudentName>StudnetName_0</StudentName>
    <StudentID>StudentID_0</StudentID>
    </Student>
    </ns0:Students>
    Please find the below xslt which you can use, it is basically based on the Muenchian grouping suggested by Ashwin
    <?xml version="1.0" encoding="UTF-16"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s0" version="1.0"
    xmlns:ns0="http://BTSTempProj.StudentDetailsOut" xmlns:s0="http://BTSTempProj.StudentDetailsIn">
      <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
      <xsl:template match="/">
        <xsl:apply-templates select="/s0:Students" />
      </xsl:template>
      <xsl:key name="groups" match="Student" use="StudentMarks"/>
      <xsl:template match="/s0:Students">
        <ns0:Students>
          <xsl:for-each select="Student[generate-id(.)=generate-id(key('groups',StudentMarks))]">
            <xsl:sort select="StudentMarks" order="ascending"/>
            <StudentMarks>
              <xsl:value-of select="StudentMarks/text()"/>
            </StudentMarks>    
            <Student>    
              <xsl:for-each select="key('groups',StudentMarks)">
                <StudentName>
                  <xsl:value-of select="StudnetName/text()"/>
                </StudentName>
                <StudentID>
                  <xsl:value-of select="StudentID/text()"/>
                </StudentID> 
                </xsl:for-each>
            </Student>
          </xsl:for-each>        
        </ns0:Students>
      </xsl:template>
    </xsl:stylesheet>
    Regards, Amit More

  • To retrieve the Maximum Date from the record

    Hi All,
    I am using the bleow query to retrieve the max date from the record list:
    select w.wr_no,w.customer_id,w.place_id, w.entry_Date, max(app.appointment_date) as appointment_date
    from work_request w , wr_appointment app
    where w.wr_no=app.wr_no
    and w.customer_id = '020167001'
    and w.place_id = '1151667'
    group by w.wr_no, w.customer_id,w.place_id, w.entry_Date;
    However i am getting the as many as three rows even after using the max function. The max date comes as the last record out the three rows retrieved.
    Thanks,
    Mark

    Mark Andrew wrote:
    And for Sven for the above customer id and place id, i receive the below result:
    WR_NO CUSTOMER_ID PLACE_ID ENTRY_DATE APPOINTMENT_DATE
    1306782233 020167001 1151667 26/07/2010 29/07/2010
    1387090103 020167001 1151667 26/02/2010 16/03/2010
    1393896673 020167001 1151667 23/01/2011 25/01/2011
    After using the rank function i will be receiving:
    WR_NO CUSTOMER_ID PLACE_ID ENTRY_DATE APPOINTMENT_DATE RK
    1393896673 020167001 1151667 23/01/2011 25/01/2011 1Now I get it.
    In fact you want to group only on the customer (and place_id?) and get all the information from the line with the last appointment date.
    Analytic functions such as RANK or ROW_NUMBER are good for this.
    The select can look like this.
    select * from (
       select w.wr_no,w.customer_id,w.place_id, w.entry_Date, app.appointment_date,
             row_number() over (partition by w.customer_id, w.place_id order by  app.appointment_date desc,  w.wr_no desc) rn
       from work_request w , wr_appointment app
      where w.wr_no=app.wr_no
      --and w.customer_id = '020167001'
      --and w.place_id = '1151667'
    where rn = 1
    ;In fact I think you can do the same operation in EXCEL directly.
    FIrst you need to sort the data by customer (asc), place (asc) and appointment date (desc).
    Then add a column in excel that give you the line where you have a new customer id.
    Assuming this new column is column H and the customerid is in column A then the function in Cell H2 would look like this.
    A function like ("=A2=A1"). Copy this formular to all the other H cells.
    Then add a auto filter on it and only select all the rows where the result is FALSE.
    Same logic as in SQL, but done in Excel.

  • Grouping on Maximum Date

    I am writing a report in CR Professional, version 11.5.9.1076 on Windows XP/Progress platform.
    I have a table that includes multiple lines per work order number and I want to group on the most recent date of approval.  I am fairly new to CR Design and am trying to figure out how to show only the most recent information and group on the approval level that was reached on the most recent date.
    EXAMPLE: 
    Data looks like this:
    WO#               DATE             Appr Lvl           Description
    1053689         2009-03-27     VOID              NEED PURCHASE ORDER
    1053689         2009-05-17     03-BILLING     APPROVED/COMPLETED BY BILLING
    1053689         2009-04-14     03-BILLING     APPROVED/COMPLETED BY BILLING
    But I want to show only the most recent date and that approval level.
    Any help you can provide is greatly appreciated!!!
    Marlene Human
    Crystal Reports Developer
    Edited by: Marlene Human on May 20, 2009 4:42 PM
    Edited by: Marlene Human on May 20, 2009 4:43 PM
    Edited by: Marlene Human on May 20, 2009 4:44 PM
    Edited by: Marlene Human on May 20, 2009 4:45 PM

    Very good, thanks.  I have been able to get the maximmum date to appear on the work order level, however I want to group by this maximum date and/or the "approval level" attached to this maximum date and what I get when I group is an instance for each approval date rather than the maximum date.
    I want the end result to be this:
    Group1: Maximum{@Approval Level} (based on maximum approval date)
    Details: {work order number}   {Max of approval date} 
    Showing this:
    Group 1:  Approval Level 3
    Details:  1053689       05/17/2009  Approval level 3
                 1053690       05/18/2009  Approval level 3
                 1053691       05/18/2009  Approval level 3

  • Error: QBVC92JY. Maximum data records exceeded

    Hi all,
    I've got a big problem with this error: Governor limit exceeded in cube generation (Maximum data records exceeded.).
    I've changed configuration in "instanceconfig.xml" where:
    <PivotView>
    <MaxCells>1000000</MaxCells>
    <CubeMaxRecords>1000000</CubeMaxRecords>
    <CubeMaxPopulatedCells>1000000</CubeMaxPopulatedCells>
    </PivotView>
    but I've still the same problem.
    Someone can help me?
    Steve

    stesappo:
    Put <CubeMaxRecords> and <CubeMaxPopulatedCells> out of <PivotView>.
    Try this in instanceconfig.xml:
    <PivotView>
    <MaxCells> 4000000 </MaxCells>
    <MaxVisibleColumns> 5000 </MaxVisibleColumns>
    <MaxVisiblePages> 2500 </MaxVisiblePages>
    <MaxVisibleRows> 50000 </MaxVisibleRows>
    <MaxVisibleSections> 3000 </MaxVisibleSections>
    <ResultRowLimit>20000</ResultRowLimit>
    </PivotView>
    <CubeMaxRecords> 1000000 </CubeMaxRecords>
    <CubeMaxPopulatedCells> 1000000 </CubeMaxPopulatedCells>
    Gabriel.

  • Error : Governor limit exceeded in cube generation (Maximum data records ex

    Hi
    I have created a report that throws this error.
    Governor limit exceeded in cube generation (Maximum data records exceeded.)
    Error Details
    Error Codes: QBVC92JY
    After going through various blog i found that i need to change the max value of pivot table view in the instanceconfig.xml file. I have added it to 500000.
    But still it throws same error.
    Ashok

    Hi Ashok,
    There are a number of setting who work in parrallel. Have a look here:
    http://obiee101.blogspot.com/2008/02/obiee-controling-pivot-view-behavior.html
    regards
    John
    http://obiee101.blogspot.com

  • Governor limit exceeded in cube generation (Maximum data records exceeded.)

    There are similar posts which didn't help in my situation.
    I had the error: Governor limit exceeded in cube generation (Maximum data records exceeded.). The query returns about *64000* rows.
    I've changed the instance config and exagerated it, and then also the register, but I still get the error:Governor limit exceeded in cube generation (Maximum data records exceeded.)
    instanceconfig:
    <?xml version="1.0"?>
    <WebConfig>
    <ServerInstance>
    <CredentialStore>
    <CredentialStorage type="file" path="C:\OracleBIData\web\config\credentialstore.xml"/>
    </CredentialStore>
         <CubeMaxRecords>5000000</CubeMaxRecords>
         <CubeMaxPopulatedCells>10000000</CubeMaxPopulatedCells>
         <ResultRowLimit>5000000</ResultRowLimit>
    <PivotView>
              <MaxVisibleRows>5000000</MaxVisibleRows>
              <MaxVisibleColumns>1024</MaxVisibleColumns>
              <MaxVisiblePages>1024</MaxVisiblePages>
              <MaxVisibleSections>1024</MaxVisibleSections>
    </PivotView>
    </ServerInstance>
    </WebConfig>
    Also added
    *<CubeMaxRecords>5000000</CubeMaxRecords>*
    *     <CubeMaxPopulatedCells>10000000</CubeMaxPopulatedCells>*
    to the registry.
    But still got the error:(
    Thanks for your help
    Edited by: user635025 on Jul 24, 2009 4:34 AM

    I suggest disabling the cache. Setting the max rows to a very high number and disabling the cache is the way to go when you are querying an Oracle database :)
    ( for those who haven't allready did the the thing )
    In NQSConfig.INI
    # Query Result Cache Section
    [ CACHE ]
    ENABLE     =     NO;

  • To find the latest Date in a group.

    Hi,
    I am having  fields  called services and a date field.I am grouping the records based on services.I want to display the records for only the latest date in that particular record.
    say for eg..if i am having dates for a particular service as
    12/31/2008
    11/30/2008
    01/31/2009
    02/04/2009
    I want to display records only for 02.04/2009.But now when i use maximum function i am getting 12/31/2008.I think it is considering only the day values.
    Can anyone please help me.
    Thanks in Advance,
    Hema

    or you can do it at report level as well, do it at database level for better performance..
    At report level, follow the steps..
    go to report main menu - > Selection formula - > group
    In the editor write the formula..
    If  maximum({Command.LATEST_ETA}) = {Command.LATEST_ETA}
    then true else false
    Hope this helps...
    Thanks
    -Azhar

  • How to display/retrieve related row data on a maximum date formula

    Here's data for one employee:
    Charge Date   Work Date   Segment
    11/05/08         11/28/08       TPLNDD
    11/07/08         11/09/08       TPLNDN
    11/21/08         11/22/08       TPLNDA
    11/26/08         11/29/08       TPLNDN
    12/11/08         12/14/08       TPLNDN
    I want to calculate the maximum "charge date" where segments in "TPLNDD", "TPLNDA".  Then, once this date is selected (11/21/08), I want to pick/retrieve the date which corresponds to that record (11/22/08).
    I would like to avoid creating a group for the maximum charge date, because I want to be able to drill down to the details and see all the records.
    Thanks, Ada

    Here you go..
    Select emp_id, charge_date, Work_date, Segment from Employee_table e
    where segment in ('TPLNDD', 'TPLNDA')
    and charge_date = (select max(charge_date) from Employee_table where segment in ('TPLNDD', 'TPLNDA') and emp_id = e.emp_id)
    Assuming you have the emp_id which is the primary key.
    Thanks
    -Azhar

  • How to Select each check box values in a group of records

    Hi,
    I have a requirement in forms 10g. In that form there are 10 records are displaying each record has one check box is there if i click the check box on record number one and record number three and do some changes in the text field(adjustment field is number data type) then finally I want to see the total on one field called total amount.
    In this my question is how to select particular records in a group of records? and finally these selected records are inserted into one table.
    Because I am not able to fetch these records at a time.
    Is there any Array to define a record group to fetch each of them individually for example Rec[1],Rec[2]...like that if yes please suggest me the steps how to do this.
    Thanks in advance
    Prasanna
    Edited by: user10315107 on Dec 17, 2008 11:44 PM

    I'm sorry, but i didn't get your requirement in detail.
    Do you want to do the summing of the selected records in forms ? Or do you just want to know which records are selected and then process them?
    If you want to process the selected records in sql you could use an object-type to store the list of id's (of whatever primary key you use), loop over the block to fill it, and then afterwards process them.
    For this approach, first create an object-type in the database:
    CREATE OR REPLACE TYPE ID_LIST AS TABLE OF NUMBER;
    /Then, in forms you could do something like this to fill a list of id's:
    DECLARE
      lIds ID_LIST:=ID_LIST();
    BEGIN
      GO_BLOCK('MYBLOCK');
      FIRST_RECORD;
      LOOP
        EXIT WHEN :SYSTEM.RECORD_STATUS='NEW';
        IF :BLOCK.CHECKBOXITEM="CHECKEDVALUE" THEN
          lIds.EXTEND(1);
          lIds(lIds.COUNT):=:BLOCK.PRIMARYKEYITEM;
        END IF;
        EXIT WHEN :SYSTEM.LAST_RECORD='TRUE';
        NEXT_RECORD;
      END LOOP;
      -- Now you can use the object-list in SQL like :
      INSERT INTO MYNEWTABLE (cols..)
      SELECT (cols..)
        FROM MYOLDTABLE
       WHERE ID IN (SELECT COLUMN_VALUE FROM TABLE(lIds));
    END;Edited by: Andreas Weiden on 18.12.2008 18:17

  • Function to Generate a Sequential incremental Number by Group of Records

    I have a table with several columns and I need to compute a sequential number by group of records
    FIELD1 FIELD2 FIELD3 FIELD4 FIELD5
    AAAAAA A1 JOHN 01/01/61 NULL
    AAAAAA A3 PAUL 01/01/71 NULL
    AAAAAA A3 MARY 01/01/02 NULL
    AAAAAA A4 CARL 01/01/04 NULL
    BBBBBB A1 MARK 01/01/60 NULL
    BBBBBB A2 ALLY 01/01/60 NULL
    BBBBBB A5 JUAN 01/01/04 NULL
    I need to compute FIELD5. This is defined as a number field.
    Records where FIELD2 = A1 the default value for FIELD5 is zero.
    I am grouping records by FIELD1, FIELD4
    The value for FIELD5 will be assigned from 1 TO 1+N
    For this sample, the resulting records will look like this;
    FIELD1 FIELD2 FIELD3 FIELD4 FIELD5
    AAAAAA A1 JOHN 01/01/61 0
    AAAAAA A3 PAUL 01/01/71 1
    AAAAAA A3 MARY 01/01/02 2
    AAAAAA A4 CARL 01/01/04 3
    BBBBBB A1 MARK 01/01/60 0
    BBBBBB A2 ALLY 01/01/60 1
    BBBBBB A5 JUAN 01/01/04 2
    Question: Can I create a function that loops through the table and compute the value for FIELD5?

    I like this idea, but because F2 must always have the value of ZERO I decided to create a procedure to calculate the value for F5.
    My procedure is below;
    The issue I am having is that I am not sure;
    1) When/where to set/reset the counter ?
    2) Determine in the inner loop if I am still whithin the same group of records ?
    3) When to update the new found value for MBR_MBR_DEP_CD field ?
    CREATE OR REPLACE PROCEDURE LC_BUILD_DEP_CODE_PROC IS
    V_ALT_ID VARCHAR2(30);
    V_EMPLOYEE_SSN VARCHAR2(9);
    --RELATIONSHIP_CD VARCHAR2(2);
    --MBR_DOB         DATE;
    V_ALT_ID_2 VARCHAR2(30);
    V_EMPLOYEE_SSN_2 VARCHAR2(9);
    V_MBR_DEP_CD_2 NUMBER(2,0);
    V_MBR_DEP_COUNTER INTEGER :=0;
    /* FIRST CURSOR */
    CURSOR GET_FAM_ALT_ID IS
    SELECT FAM.ALT_ID,
    FAM.EMPLOYEE_SSN
    FROM TPA_MBR_STG FAM
    WHERE FAM.RELATIONSHIP_CD = '18'
    ORDER BY FAM.ALT_ID;
    /* SECOND CURSOR */
    CURSOR GET_MBR_DEP_CD IS
    SELECT MBR.ALT_ID,
    MBR.EMPLOYEE_SSN,
    MBR.MBR_DOB,
    MBR.MBR_DEP_CD
    FROM TPA_MBR_STG MBR
    --WHERE MBR.ALT_ID = V_ALT_ID
    --AND   MBR.EMPLOYEE_SSN = V_EMPLOYEE_SSN
    WHERE MBR.RELATIONSHIP_CD <> '18'
    ORDER BY MBR.ALT_ID, MBR.MBR_DOB;
    BEGIN
    -- OPEN FIRST CURSOR
    OPEN GET_FAM_ALT_ID;
    LOOP
    FETCH GET_FAM_ALT_ID INTO V_ALT_ID,
    V_EMPLOYEE_SSN;
    OPEN GET_MBR_DEP_CD;
    FETCH GET_MBR_DEP_CD INTO V_ALT_ID_2,
    V_EMPLOYEE_SSN_2;
    IF V_ALT_ID_2 = V_ALT_ID
    AND V_EMPLOYEE_SSN_2 = V_EMPLOYEE_SSN
    THEN
    LOOP
    V_MBR_DEP_COUNTER = V_MBR_DEP_COUNTER + 1;
    UPDATE TPA_MBR_STG
    SET MBR_MBR_DEP_CD = V_MBR_DEP_COUNTER;
    END LOOP;
    END IF;
    CLOSE GET_MBR_DEP_CD;
    V_MBR_DEP_COUNTER :=0;
    END LOOP;
    CLOSE GET_FAM_ALT_ID;
    EXCEPTION
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR(-20001,'AN ERROR WAS ENCOUNTERED - '||SQLCODE||' -
    ERROR- '||SQLERRM);
    END LC_BUILD_DEP_CODE_PROC;

  • Oracle Maximum Date Query

    i need assistance in creating a query
    select a.job_number, a.title, a.request_date, a.completion_date, b.modification_number,b.actual_cost, b.shop_facility_percentage, d.status_date
    from
    survey_jobs a
    left outer join survey_job_bundles b
    on (a.survey_job_id = b.survey_job_id)
    left outer join survey_job_status d on (b.survey_job_bundle_id = d.survey_job_bundle_id)
    order by a.job_number asc, b.modification_number asc
    this query produces a report that duplicates some of the rows. it does this because i am joining to a child to table that has a one to many relationship with its parent. The child table can have many dates (d.status_date). I want to pull the maximum date from this child table. I have created a max function that i was trying to plug in, but when i plug it in right under the last outer join, it reduces my report results.
    here is my attempted max function
    AND b.SURVEY_JOB_BUNDLE_ID = d.SURVEY_JOB_BUNDLE_ID
    AND ((d.SURVEY_JOB_BUNDLE_ID IS NULL) OR
    (d.SURVEY_JOB_BUNDLE_ID, d.STATUS_DATE) IN
    (SELECT SURVEY_JOB_BUNDLE_ID, MAX(STATUS_DATE) FROM
    SURVEY_JOB_STATUS GROUP BY SURVEY_JOB_BUNDLE_ID))
    Can anyone help me with this? Thanks in advance
    Edited by: 963510 on Jan 9, 2013 11:17 AM
    Edited by: 963510 on Jan 9, 2013 11:22 AM
    Edited by: 963510 on Jan 9, 2013 11:23 AM

    GROUP BY the maximum date. You may want to then wrap that query in parentheses as an inline view and query it as an intermediate result set.
    BTW: Always post a version number, Always read the FAQ and learn how to post properly ... for example using tags, Always include DDL for the table and some sample data so people can try out a solution. We do not always have time to reinvent the wheel.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How much Maximum data preferred from XI

    Hi Friends,
    How much it Maximum data is preferred to transfer the XI.I have the approxmately 170 MB of data,This message is struck in queue(SMQ2) from past four days still "Transaction Running" Status and SXMB_Moni shows the Block arrow with status called " Recorded for outbound processing".
    If i use the small amount of data XI reached target side successfully, But in case of large amount message is struck in SMQ2.
    In my scenario real time data having the large amount only.
    Can you please suggest me .
    Thank you ,
    Sateesh

    Hi Sateesh,
    How much it Maximum data is preferred to transfer the XI.
    Its depends on your hardware configuration:
    a. No CPUs, b. Memory, c. No of Java Server nodes, d. No of Application Servers
    You can set the vlue of the parameter EO_MSG_SIZE_LIMIT under category TUNING from 0-2097,151 KB in SXMB_ADM...
    Also refer the following blogs...
    /people/aayush.dubey2/blog/2007/10/10/zip-transfer-unzip-increase-the-performance-of-your-java-abap-applications
    /people/alessandro.guarneri/blog/2006/03/05/managing-bulky-flat-messages-with-sap-xi-tunneling-once-again--updated
    regds,
    Pinangshuk.

  • Search on Maximum Date Formula Field

    Hello All,
    I am trying to create a report that will return a PART table linked with an outer join to an ORDERDTL table.
    What I would like to do is to return only the Maximum (or last) order date for each part and then have a parameter field that will give me a cutoff date for the last ordered.
    For example:  Part ABC was ordered on 1/1/08 and 1/1/07.  Part XYZ was ordered on 1/1/07 and 1/1/06.  When I enter a cutoff date of 2/1/07 it should return part XYZ but NOT part ABC because ABC was ordered after the cutoff date.
    I can see the parameter being "only return the parts with a maximumdate NOT > parameterdate".  I am having trouble getting the maximum date to be available for query. 
    How do I run a date parameter field against a Formula field with a maximum date?
    Any other pointers?
    Thanks,
    Ross

    you need to create a formula MAXIMUM(DATE) i would have it subtotal on a group, i guess your part #.
    then in the selection criteria, in the group selection you can use that or use a conditional surpression based upon the parameter

Maybe you are looking for

  • Noisy CD/DVD drive on my Satellite A60

    Hi I have a Satellite A60 and for some reason the CD/DVD drive makes a terrible noise on some CDs and DVDs but not on others. It sounds as though the CD is rubbing on something but it is not as it now makes this noise with CDs that i have played for

  • Authorization object L_LGNUM

    Dear colleagues, I am trying to restrict a user from doing a certain 'thing' and am looking for your help. In Warehouse Management we are confirming Transfer Orders in Two steps. I want the user that does the first step, not to be able to confirm the

  • CS3 Updates cause programs to not work with Windows 7?

    Has anyone else had their programs stop working after an Adobe update was installed?  Although I have been told by 5 different Adobe staff members that CS3 is "not at all compatible" with Windows 7...it somehow worked on two machines for 6 months.  T

  • JAR file required

    Hi to all, I've required to include jdbc.driver.jar file in my lib directory for some ant operation. Can any help me to download jdbc.driver.jar file ? I try but I can't find url to download jdbc.driver.jar file. Regards -Shobhit

  • I accendentally clicked something that made everything pertaining to the address bar disapear. How do I ge that back?

    I accidentally clicked something that made everything pertaining to the address bar disappear. (the home button, the refresh button, and the back arrows. also the ability to click on the folders like "file", or "edit") How do I get that back?