Note that there are some explanatory texts on larger screens.

plurals
  1. POColdfusion cfchart stacked order
    primarykey
    data
    text
    <p>I have a couple of queries which pull data for use in a graph.</p> <pre><code>&lt;cfquery name='clusterPrivateReferrals' dbtype="query"&gt; SELECT organisationName, count(messageID)*1000/listSize as msgCount FROM clusterReferrals WHERE datecreated&gt;#refRateStartDate# AND refTypeID=3 GROUP BY organisationName, listSize &lt;/cfquery&gt; &lt;cfquery name='clusterNHSReferrals' dbtype="query"&gt; SELECT organisationName, count(messageID)*1000/listSize as msgCount FROM clusterReferrals WHERE datecreated&gt;#refRateStartDate# AND refTypeID&lt;&gt;3 GROUP BY organisationName, listSize &lt;/cfquery&gt; </code></pre> <p>The graph code is</p> <pre><code>&lt;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"&gt; &lt;cfchartseries type="bar" seriescolor="##FFD800" seriesLabel="Private" query="clusterPrivateReferrals" valueColumn="msgCount" ItemColumn="organisationName"&gt; &lt;/cfchartseries&gt; &lt;cfchartseries type="bar" seriescolor="##F47D30" seriesLabel="NHS" query="clusterNHSReferrals" valueColumn="msgCount" ItemColumn="organisationName"&gt; &lt;/cfchartseries&gt; &lt;/cfchart&gt; </code></pre> <p>this gives me the following graph</p> <p><img src="https://i.stack.imgur.com/VPY7j.jpg" alt="alt text"></p> <p>How do I get the data displayed sorted by the total of the stacked elements? </p> <p>@ Ben</p> <p>That got me on the right track, I didnt previously know QOQ could combine 2 completely different queries</p> <pre><code>&lt;cfquery name='clusterPrivateReferrals' dbtype="query"&gt; SELECT organisationName, count(messageID)*1000/listSize as privateRate FROM allReferrals WHERE datecreated&gt;#refRateStartDate# AND refTypeID=3 GROUP BY organisationName, listSize &lt;/cfquery&gt; &lt;cfquery name='clusterNHSReferrals' dbtype="query"&gt; SELECT organisationName, count(messageID)*1000/listSize as nhsRate FROM allReferrals WHERE datecreated&gt;#refRateStartDate# AND refTypeID&lt;&gt;3 GROUP BY organisationName, listSize &lt;/cfquery&gt; &lt;cfquery name="stackOrder" dbtype="query"&gt; 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 &lt;/cfquery&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload