I have a couple of queries which pull data for use in a graph.
<cfquery name='clusterPrivateReferrals' dbtype="query">
SELECT organisationName, count(messageID)*1000/listSize as msgCount
FROM clusterReferrals
WHERE datecreated>#refRateStartDate#
AND refTypeID=3
GROUP BY organisationName, listSize
</cfquery>
<cfquery name='clusterNHSReferrals' dbtype="query">
SELECT organisationName, count(messageID)*1000/listSize as msgCount
FROM clusterReferrals
WHERE datecreated>#refRateStartDate#
AND refTypeID<>3
GROUP BY organisationName, listSize
</cfquery>
The graph code is
<cfchart format="flash" title="Cluster referrals per 1000 patients from #dateformat(refRateStartDate, 'dd-mmm-yy')#" chartWidth="470" chartHeight="380" fontSize="12" style="chart.xml" seriesPlacement = "stacked" showLegend = "yes">
<cfchartseries type="bar" seriescolor="##FFD800" seriesLabel="Private" query="clusterPrivateReferrals" valueColumn="msgCount" ItemColumn="organisationName">
</cfchartseries>
<cfchartseries type="bar" seriescolor="##F47D30" seriesLabel="NHS" query="clusterNHSReferrals" valueColumn="msgCount" ItemColumn="organisationName">
</cfchartseries>
</cfchart>
this gives me the following graph
How do I get the data displayed sorted by the total of the stacked elements?
@ Ben
That got me on the right track, I didnt previously know QOQ could combine 2 completely different queries
<cfquery name='clusterPrivateReferrals' dbtype="query">
SELECT organisationName, count(messageID)*1000/listSize as privateRate
FROM allReferrals
WHERE datecreated>#refRateStartDate#
AND refTypeID=3
GROUP BY organisationName, listSize
</cfquery>
<cfquery name='clusterNHSReferrals' dbtype="query">
SELECT organisationName, count(messageID)*1000/listSize as nhsRate
FROM allReferrals
WHERE datecreated>#refRateStartDate#
AND refTypeID<>3
GROUP BY organisationName, listSize
</cfquery>
<cfquery name="stackOrder" dbtype="query">
select clusterPrivateReferrals.privateRate,
clusterNHSReferrals.nhsRate,
clusterPrivateReferrals.organisationName,
(clusterPrivateReferrals.privateRate + clusterNHSReferrals.nhsRate) as totalRate
from clusterPrivateReferrals, clusterNHSReferrals
WHERE clusterNHSReferrals.organisationName = clusterPrivateReferrals.organisationName
order by totalRate desc
</cfquery>