I'm having some issues with the ColdFusion Report Builder...
I have a database table called "Items" that includes fields for Reviewer and Status. I want to create a report that will list a reviewer, then express the number of items where the Status is "open" as a total or record count. I want to do the same for total items, and then express the number of "open" items as a percentage. For example:
REVIEWER, OPEN ITEMS, TOTAL ITEMS, PERCENT OPEN
John Doe, 10, 20, 50%
Jane Smith, 15, 60, 25%
...and so on.
So far I've only been able to get my report to display the recordcount of the entire query. In order troubleshoot the problem I created a regular cfm page to do the same thing. Here's what I did:
<cfquery name="getreviewers" datasource="#APPLICATION.datasource#">
SELECT DISTINCT Reviewer
FROM Items
ORDER BY Reviewer
</cfquery>
<cfoutput query="getreviewers">
<cfquery name="getopenitems" datasource="#APPLICATION.datasource#">
SELECT Status
FROM Items
WHERE Status='open'
AND Reviewer = '#Reviewer#'
</cfquery>
<cfset open = getopenitems.recordcount>
<cfquery name="getallitems" datasource="#APPLICATION.datasource#">
SELECT Status
FROM Items
WHERE Reviewer = '#Reviewer#'
</cfquery>
<cfset all = getallitems.recordcount>
<cfset percent = (open / all) * 100>
#getreviewers.DR_Item_Reviewer#, #open#, #all#, #Round(percent)#%
</cfoutput>
That worked great, but as you can see I had to nest a couple of queries inside a <cfoutput>. I don't know how to incorporate this into the report builder, as it seems you can only specify a single query. Another thing that occurs to me is perhaps I'm going about this the wrong way. Is there perhaps a function that will display things the way I want them without fussing with multiple queries? Any help would be greatly appreciated. Thanks in advance.
I have a database table called "Items" that includes fields for Reviewer and Status. I want to create a report that will list a reviewer, then express the number of items where the Status is "open" as a total or record count. I want to do the same for total items, and then express the number of "open" items as a percentage. For example:
REVIEWER, OPEN ITEMS, TOTAL ITEMS, PERCENT OPEN
John Doe, 10, 20, 50%
Jane Smith, 15, 60, 25%
...and so on.
So far I've only been able to get my report to display the recordcount of the entire query. In order troubleshoot the problem I created a regular cfm page to do the same thing. Here's what I did:
<cfquery name="getreviewers" datasource="#APPLICATION.datasource#">
SELECT DISTINCT Reviewer
FROM Items
ORDER BY Reviewer
</cfquery>
<cfoutput query="getreviewers">
<cfquery name="getopenitems" datasource="#APPLICATION.datasource#">
SELECT Status
FROM Items
WHERE Status='open'
AND Reviewer = '#Reviewer#'
</cfquery>
<cfset open = getopenitems.recordcount>
<cfquery name="getallitems" datasource="#APPLICATION.datasource#">
SELECT Status
FROM Items
WHERE Reviewer = '#Reviewer#'
</cfquery>
<cfset all = getallitems.recordcount>
<cfset percent = (open / all) * 100>
#getreviewers.DR_Item_Reviewer#, #open#, #all#, #Round(percent)#%
</cfoutput>
That worked great, but as you can see I had to nest a couple of queries inside a <cfoutput>. I don't know how to incorporate this into the report builder, as it seems you can only specify a single query. Another thing that occurs to me is perhaps I'm going about this the wrong way. Is there perhaps a function that will display things the way I want them without fussing with multiple queries? Any help would be greatly appreciated. Thanks in advance.