I am new to access. I have a report with a query(Q1) as its data source. Is it possible to use another query(Q2) only for one field in the same report?
My main query is:
SELECT PersonTotalHours.*, Person.*
FROM PersonTotalHours
INNER JOIN Person
ON PersonTotalHours.LastName = Person.LastName;
My report's structure is like this:
Report header
_____________
Page header
_____________
Lastname header
_____________
report details
_____________
Lastname Footer
_____________
PageFooter
As you can see, in the report I group my data using the Lastname column then I show details about each peron for current year.
I need to show short form of data about former years of each person in the Last name header (somewhere before the detailed data).
Second query is like this:
SELECT PersonTotalHours.MA, PersonTotalHours.Year, Sum(PersonTotalHours.Hours) AS Sum
FROM PersonTotalHours
GROUP BY PersonTotalHours.MA, PersonTotalHours.Year
I use this for short form of data.
Important point is that the number of rows can be different. Person A might have 0 previous years and another person has more than 5.
How is it possible to use the second query for parts of report data?
I solve the problem using a subreport.
http://www.simply-access.com/Multiple-Queries-in-Report.html
Related
I am trying to update a Crystal Report with a new column. This report ("Employee Roster") looks at one table (PREH) and puts out some details, the important ones being Employee, Company, and Craft. The user specifies parameters (Company, Craft, specific Employee [optional]) and the report spits out all employees for that craft/date range and a few other details for them.
I want to add another column for their "HoursWorked" in a given craft, the details of which are found in a different table, PRTH. In PRTH there is one line for each "hours added" entry, and there may be hundreds or thousands of these for a given employee. The SQL for this would be something like:
SELECT SUM(Hours)
FROM dbo.PRTH
WHERE PRTH.Employee=%Employee
AND PRTH.Craft=%Craft
AND PRTH.Company=%Company
AND PRTH.EarnCode NOT IN ('5','6','52','60','100','103')
The main problem I'm finding is that I can't just do a simple join, as that causes a lot of row bloat. Right now the report puts out one line for each employee (grouping by craft) - if I join the table I need, then it makes a LOT of lines for each employee. I want to add just the summary of Hours, based off the current employee that's being looked at in the Details section. I can do what I want in SQL but am not sure how to pass that on in Crystal Reports, ultimately trying to use results of the main report as parameters in this second search.
Any help is greatly appreciated, thank you.
SAMPLE OUTPUT FOR CURRENT REPORT (Parameters=Company 1, Craft=46T)
EE# SortName FullName Co Craft
1553 BOBJONES Jones, Bob 1 46T
1672 RACHELJONES Jones, Rachel 1 46T
2007 TANYAADAMS Adams, Tanya 1 46T
In the above output, I'd be trying to add a new Column "TotalHours". For the first line, I'd expect it to run the SQL statement using Bob Jones' EE for "%Employee", his Craft for "%Craft", and his Company for "%Company".
It sounds like what you're trying to achieve is just this:
SELECT [EE#], SortName, FullName, Co, Craft,
(SELECT SUM(Hours)
FROM dbo.PRTH
WHERE PRTH.Employee=e.Employee
AND PRTH.Craft=e.Craft
AND PRTH.Company=e.Company
AND PRTH.EarnCode NOT IN ('5','6','52','60','100','103')) AS TotalHours
FROM TableWithEmployees AS e
WHERE PRTH.Employee=%Employee
AND PRTH.Craft=%Craft
AND PRTH.Company=%Company;
Is that what you mean?
Can anyone help me create chart like the one below? I'm using CFDB on wordpres. It is a simple form inputs counter.
I've figured out something like this:
SELECT month(FROM_UNIXTIME(`submit_time`)) as miesiac,
year(FROM_UNIXTIME(`submit_time`)) as rok,
`form_name`, `field_name`, `field_value`, `field_order`, `file`
FROM `wp_cf7dbplugin_submits`
WHERE year(FROM_UNIXTIME(`submit_time`)) = 2016
I would like to get final result like in the attachment.
Now I get something like this one:
enter image description here
In order to generate the data needed for a chart like the one in your example, you need to return the number of form submissions for each month and form type.
SELECT COUNT(sub.form_name) as total, sub.form_name, sub.miesiac
FROM (
SELECT DISTINCT `submit_time`, month(FROM_UNIXTIME(`submit_time`)) as miesiac,
`form_name`
FROM `wp_cf7dbplugin_submits`
WHERE year(FROM_UNIXTIME(`submit_time`)) = 2016 ) sub
GROUP BY sub.form_name, sub.miesiac
The sub-query identifies the distinct submissions (since each submission has multiple rows) and the main query counts the number of submissions for each form type per month. There's no need to include the year because it's already included in the WHERE statement.
I am trying to set up the following report so that it is grouped first by "Transfer-In Unit" (d1_10.xinstitute), which is the title of a column that is included in a sub-report, and second by xpid, which is a patient index number used in all tables (except a catalog) in this report. To simplify this question, assume that xpid is indexed in alphabetical order of the patients' names.
See info/examples below:
This report shows patients that have transferred out of a specific unit since the user-inputted date (Name), a row for each date that the patient transferred out of a particular unit (Unit M Transfer-Out Date), chronologically where they next transferred into (Transfer-In Unit), and when they transferred into that unit (Transfer-In Date).
Currently without attempting this grouping the output looks like this:
Name and Unit M Transfer-Out Date are on the parent report
Transfer-In Unit and Transfer-In Date are in a subreport because they both call d1_10.dstartdate but with different criteria.
The goal is to sort by Transfer-In Unit, which is a column in the subreport.
The output should be:
An underlying issue is that to select the chronological next transfer-in following a transfer-out, I have to select a minimum transfer date grouped by xpid. This causes the requirement of an xpid grouping in the sub-report.
I have tried a grouping by d1_10.xinstitute (the unit index) in both the parent- and sub-reports. In the parent report it creates one all-encompassing group, because every row in this report represents someone transferring out of "Unit M". In the subreport it seems to apply the groupings row by row, so each row has two groups, even when the next row is the same patient transferring into the same unit. However this is my best attempt and it looks like this:
Any help/thoughts/ideas much appreciated. Let me know if I can provide any further info.
Thanks
Very new to Pentaho Reporting,
I have a query grabbing columns categories, quantity, and gross. It returns about 200 rows.
Without changing the query, is there a way for the report to display the aggregates for each category (I have category as a group)? For example, All you can eat should only display a sum of the Amount and GrossValue columns.
Same for dessert (notice there are two group headers - why?)
You just need to get used to with pentaho report designer.
Refer information given at the end of this page simple report.
You can add one parameter in group footer and set its properties.
They provides properties like aggregation-type, which can be set as Sum or count and then it will show at the end of each group with sum or count of the rows as per the type you specified.
I've got two reports that I wish to combine into one print off. Report1 is a 2 page report and has an ID parameter, Report2 is a 1 page report and also has the same ID parameter. The ID's come from a separate query dataset1
SELECT id FROM users WHERE firstname = 'Dave'
I want there to be 3 pages per id. I have tried putting two subreports into a List, where the list has a dataset linked to my SELECT query, but this displays all of the Report1's and then all of the Report2's after.
Desired output: (Report1pg1[id=1], Report1pg2[id=1], Report2pg1[id=1]), (Report1pg1[id=2], Report1pg2[id=2], Report2pg1[id=2])
I am not sure and i don't have no data tools installed in my current machine to check.
But I think the following logic will work.
Try grouping with id in Report1 and in detail portion add subreport and call Report2 (assuming that you are using table)