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
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 PMHi,
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 -
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 AMGROUP 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. -
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,
Rossyou 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 -
Dynamically group records by date
I am attempting to create a report that will dynamically group records into a set number of date buckets. This is similar to grouping records by a date field and setting the days, weeks, months, etc property but instead of grouping by a set time span I want to a specific number of date groups regardless of date span. So say i have records where the first date is today at 1am and the last record is today at 9 pm. I want the data grouped into 10 groups and the time calculated for that group based on total time span / 10. The first group would be 1AM to 3AM, the second would group 3AM to 5AM, etc.. The reason I am doing this is for a chart that displays record counts over time but the overall timespan will never be known until runtime. Setting the chart for hourly or weekly doesn't work because if the user runs the report over a year the dates will be illegible.
Thanks in advance!Well this SHOULD be easy. But leave it to CR make not...
You can start by finding the minimum & maximum dates within your range:
Local DateTimeVar MinDate;
MinDate := Minimum({Table.DateField})
and
Local DateTimeVar MaxDate;
MaxDate := Maximum({Person.ModifiedDate})
Then figure out what the the interval would be if the span is broken down into 10 equal parts"
DateDiff("n", {@MinDate}, {@MaxDate}) / 10
From there just use a formula to segregate each records into the appropriate groups:
EvaluateAfter({@Interval});
IF {Table.DateField} >= {@MinDate}
AND {Table.DateField} <= DateAdd("n",{@Interval}, {@MinDate}) THEN 1 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval}, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 2, {@MinDate}) THEN 2 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 2, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 3, {@MinDate}) THEN 3 ELSE
IF{Table.DateField} > DateAdd("n",{@Interval} * 3, {@MinDate})
AND{Table.DateField} <= DateAdd("n",{@Interval} * 4, {@MinDate}) THEN 4 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 4, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 5, {@MinDate}) THEN 5 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 5, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 6, {@MinDate}) THEN 6 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 6, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 7, {@MinDate}) THEN 7 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 7, {@MinDate})
AND{Table.DateField} <= DateAdd("n",{@Interval} * 8, {@MinDate}) THEN 8 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 8, {@MinDate})
AND {Table.DateField} <= DateAdd("n",{@Interval} * 9, {@MinDate}) THEN 9 ELSE
IF {Table.DateField} > DateAdd("n",{@Interval} * 9, {@MinDate})
AND {Table.DateField} <= {@MaxDate} THEN 10
This is where CR drops the ball... IMHO... it WON'T allow you to to group by a formula field that uses an aggregate in the formula (in this case Minimum & Maximum)... It will however allow to to graph on it, which I assume is what you are actually trying to do. If anyone knows a way to work around the grouping issue, I'd love to know it myself.
HTH,
Jason -
Post Author: tadj188#
CA Forum: Formula
Needed: Sum of LineCount Including Groups and Detail Data On Each Page Used To Generate New Page If TotalPageLineCount > 28
Background:
1) Report SQL is created with unions to have detail lines continue on a page, until it reaches page footer or report footer, rather than using subreports. A subreport report is now essentially a group1a, group1b, etc. (containing column headers and other data within the the report with their respective detail lines). I had multiple subreports and each subreport became one union.
Created and tested, already:
1) I have calculated @TotalLineForEachOfTheSameGroup, now I need to sum of the individual same group totals to get the total line count on a page.
Issue:
1) I need this to create break on a certain line before, it dribbles in to a pre-printed area.
Other Ideas Appreciated:
1) Groups/detail lines break inconveniently(dribble) into the pre-printed area, looking for alternatives for above situation.
Thank you.
Tadjexport all image of each page try like this
var myDoc = app.activeDocument;
var myFolder = myDoc.filePath;
var myImage = myDoc.allGraphics;
for (var i=0; myImage.length>i; i++){
app.select(myImage[i]);
var MyImageNmae = myImage[i].itemLink.name;
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high;
app.jpegExportPreferences.exportResolution = 300;
app.selection[0].exportFile(ExportFormat.JPG, File(myFolder+"/"+MyImageNmae+".JPEG"), false);
alert(myImage[i].itemLink.name) -
How to select maximum date in report
i have tried to select maximum date in my report by this way:
select max(date) from a
but the result came out same as "select date from a"
there is no different whether i put a max or not. is anyone there can help me on this please....
Thank you....Hi Sharon,
Since you cannot execute this query from SQL, I assume that the DB does not support the function MAX(expr). Am not sure which DB versions support this function, probably the Database forum will be a better place to ask that.
As a workaround, what you could try is to use this statement
select hire_date from employees order by hire_date desc
and in the report data model, you make a summary column and choose Function > First, Source > Hire_Date, and Reset At > Report.
Hope that helps.
Navneet. -
What is the maximum,data we can pull in BI-7.0 a day.
Hi,
All, there is a small isuue standing, can any one tell me as to how much data can we pull in a dfay my client wants to pull 250k a day is it possible?
Somebody pls give me the specifications as to how much of maximum data can we pull in BI-7.0, in a day .
Thanks in advance,
Point's will be awarded
Regards
KittuKittu,
We don't have any Measurements... it's all depends on your Hardware.. DB Background Process etc.
In my last client(3.1C), we used pull daily delta around 150K to 250K. we didn't have any Isuues.
Nagesh Ganisetti.
Assign points if it helps. -
How to find out Maximum date value in RPD.
Hi All,
I have a date column i want to get the maximum date value from that column. I am trying this expression MAX( "sales"."book"."date") in new logical column i am getting the RPD inconsistence error. Database is SQL server 2005. Is there any problem in my syntax?
Thanks in advance.Is that column date part of time dimension?
What does error say? syntax should be ok - maybe something to do with your DB settings in physical layer.
can you try to create the same column in Answers? (select fx button of the column and then add MAX ( ) around the column.
Edited by: wildmight on Jun 12, 2009 10:09 AM -
Maximum Data file size in 10g,11g
DB Versions:10g, 11g
OS & versions: Aix 6.1, Sun OS 5.9, Solaris 10
This is what Oracle 11g Documentation
http://download.oracle.com/docs/cd/B28359_01/server.111/b28320/limits002.htm
says about the Maximum Data file size
Operating system dependent. Limited by maximum operating system file size;typically 2^22 or 4 MB blocksI don't understand what this 2^22 thing is.
In our AIX machine and ulimit command show
$ ulimit -a
time(seconds) unlimited
file(blocks) unlimited <-------------------------------------------
data(kbytes) unlimited
stack(kbytes) 4194304
memory(kbytes) unlimited
coredump(blocks) unlimited
nofiles(descriptors) unlimited
threads(per process) unlimited
processes(per user) unlimitedSo, this means, In AIX that both the OS and Oracle can create a data file of any Size. Right?
What about 10g, 11g DBs running on Sun OS 5.9 and Solaris 10 ? Is there any Limit on the data file size?How do i determine maximum number of blocks for an OS?df -g would give you the block size. OS blocksize is 512 bytes on AIX.
Lets say the db_block_size is 8k. What would the maximum file size for data file in Small File tablespace and Big File tablespace be?Smallfile (traditional) Tablespaces - A smallfile tablespace is a traditional Oracle tablespace, which can contain 1022 datafiles or tempfiles, each of which can contain up to approximately 4 million (222) blocks. - 32G
A bigfile tablespace contains only one datafile or tempfile, which can contain up to approximately 4 billion ( 232 ) blocks. The maximum size of the single datafile or tempfile is 128 terabytes (TB) for a tablespace with 32K blocks and 32TB for a tablespace with 8K blocks.
HTH
-Anantha -
Count(*) with group by max(date)
SQL> select xdesc,xcust,xdate from coba1 order by xdesc,xcust,xdate;
XDESC XCUST XDATE
RUB-A 11026 01-JAN-06
RUB-A 11026 05-JAN-06
RUB-A 11026 08-JAN-06
RUB-A 11027 10-JAN-06
RUB-B 11026 02-JAN-06
RUB-B 11026 08-JAN-06
RUB-B 11026 09-JAN-06
RUB-C 11027 08-JAN-06
I want to make sql that result :
XDESC COUNT(*)
RUB-A 2
RUB-B 1
RUB-C 1
Criteria : GROUPING: XDESC XCUST AND MAX(DATE)
bellow mark *** that was selected in count.
XDESC XCUST XDATE
RUB-A 11026 01-JAN-06
RUB-A 11026 05-JAN-06
RUB-A 11026 08-JAN-06 ***
RUB-A 11027 10-JAN-06 ***
---------------------------------------------------------COUNT RUB-A = 2
RUB-B 11026 02-JAN-06
RUB-B 11026 08-JAN-06
RUB-B 11026 09-JAN-06 ***
---------------------------------------------------------COUNT RUB-B = 1
RUB-C 11027 08-JAN-06 ***
--------------------------------------------------------COUNT RUB-C = 1
Can Anybody help ?
I tried :
select xdesc,max(xdate),count(max(xdate)) from coba1 group by xdesc
ERROR at line 1:
ORA-00937: not a single-group group function
ThankThis one is duplicate. see the following link
Count(*) with group by max(date)
Thanks -
Oracle Database Express Edition maximum data size
Hi
We just need to know what is the maximum data(in gb) Oracle database express edition 10g can store in it?
Thanks915071 wrote:
Hi
We just need to know what is the maximum data(in gb) Oracle database express edition 10g can store in it?
Thanks4GB -
What is the Maximum Data can a file adapter can send at a time.
Hi ,
What is the Maximum Data can a file adapter can send at a time.Is there any maximum limit data can adapters will send.
can any one help on this.
regrads
RaghuHi Reddy,
I have raised the same question and I got correct answer.
Refer the below thread which will give u information.
Wat is the maximu size of data XI can handle
Thnx
Chirag -
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 ,
SateeshHi 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. -
Payment Medium Workbench - Group by Posting Date
I have made a medium format with DMEE Engine but it doesn't work as I would like.
I want to have a file with all items group by posting date (subtotals group by posting date, no depends on vendor).
I have 2 leveles:
- Level 1: Repetition Factor 1 and Key Field FPAYP-FAEDT (Posting Date)
- Level 2: Repetition Factor 999999 and Key Field FPAYP-DOC2R (Document unique key)
However when I execute F110 transaction it generates different files, WHY?
One file per vendor and posting date, but I WANT TO HAVE A UNIQUE FILE.
Example
Vendor Posting Date Ammount
ITEM 1: xx 15/10/2007 100
ITEM 2: xx 15/10/2007 200
ITEM 3: yy 15/10/2007 300
ITEM 4: xx 21/10/2007 400
ITEM 5: zz 21/10/2007 500
Output (wrong)
FILE1:
15/10/2007
xx 100
xx 200
300
FILE2:
15/10/2007
yy 300
300
FILE3:
21/10/2007
xx 400
400
FILE4:
21/10/2007
zz 500
500
Output (ok)
FILE1:
15/10/2007
xx 100
xx 200
yy 300
600
21/10/2007
xx 400
zz 500
900
Thanks in advanced!Ok, the problem has been fixed.
The repetition factor for level 1 (Posting Date) should be 9999999 instead of 1, beacuse it refers to input data and it doesn't refer to output data.
We can have differents posting dates in input data, but we want to have a unique line by posting date in output data.
Regards!
Maybe you are looking for
-
The new look iOS 7 is all "pretty" turquoises, lime greens and sky blue and the size of my Apps filed in their boxes are so tiny as to be illegible and the names in Contacts etc are allmuch, much smaller and totally impossible to read. I absolutely h
-
Issue in elementary search help.
Hi, Facing some issue on Attaching search help directly to the screen Fields. I have a requirement that 1> Based on a screen field, I have to filter F4 for the other fields. 2> I have to populate 2 screen elements at the same time. Like: In my transa
-
Problem in dynamic selection screen
Hi, I have a parameter P1 on the selection screen.When i am entering some value in that field some more field should be displayed below it on the selection screen.For ex. when i am entering 1 P2,P3,P4 should come.Whe i am entering 2 P3,P4,P5 should
-
Can a display image field be changed with javascript
I have a select list (P3_RECON_CONDITION). when it changes It triggers javascript.. in that javascript I would like it to change a Display Image field (P3_RECON_COLOR) without having to refresh the whole page.. P3_RECON_COLOR is a Display image filed
-
How the hell do you stop ATI Catalyst from controling the colours?!
Hi all, I've posted this on the ATI website but thought I'd try here for some expertise from the Adobe people because this has to do with colour profiles and people here may know more. This is beginning to annoy me. Sorry for the bad tempered start.