<?xml version="1.0" encoding="UTF-8"?>
<action-sequence> 
  <title>Barchart Data</title>
  <version>1</version>
  <logging-level>debug</logging-level>
  <documentation> 
    <author>Gretchen Moran</author>  
    <description>Return the variance between headcount actual and budget for every department</description>  
    <help/> 
  </documentation>

  <inputs/>

  <outputs> 
    <rule-result type="result-set"/> 
  </outputs>

  <resources/>
  
  <!-- Define an input called 'REGION'. This will be passed in when the user clicks on a slice of the pie chart -->  
  <!-- Define an output called 'rule-result' -->  
  <!-- This action sequence does not require any external resources -->  
  <actions> 
    <action-definition> 
      <!-- Define a local input called 'REGION' -->  
      <component-name>SQLLookupRule</component-name>
      <action-type>Query For Variance Data</action-type>
      <action-inputs/>
      <action-outputs> 
        <query-result type="result-set" mapping="rule-result"/> 
      </action-outputs>
      <component-definition> 
        <!-- Define the datasource for the query -->  
        <jndi>SampleData</jndi>  
        <source>sql</source>  
        <!-- Define the query to execute. Note the parameter {REGION} in the query -->  
        <query><![CDATA[SELECT CONCAT(CONCAT(CONCAT('Q', QUARTER(ORDERS.ORDERDATE)),'-'),YEAR(ORDERS.ORDERDATE)) AS TIME, SUM(ORDERDETAILS.QUANTITYORDERED*ORDERDETAILS.PRICEEACH) SOLD_PRICE 
FROM ORDERS 
INNER JOIN ORDERDETAILS ON ORDERS.ORDERNUMBER = ORDERDETAILS.ORDERNUMBER 
INNER JOIN PRODUCTS ON ORDERDETAILS.PRODUCTCODE =PRODUCTS.PRODUCTCODE  
INNER JOIN CUSTOMERS ON ORDERS.CUSTOMERNUMBER =CUSTOMERS.CUSTOMERNUMBER  
INNER JOIN EMPLOYEES ON CUSTOMERS.SALESREPEMPLOYEENUMBER = EMPLOYEES.EMPLOYEENUMBER
INNER JOIN OFFICES ON EMPLOYEES.OFFICECODE=OFFICES.OFFICECODE


GROUP BY
CONCAT( YEAR(ORDERS.ORDERDATE), QUARTER(ORDERS.ORDERDATE))]]></query> 
      </component-definition>  
      <!-- Define a local output called 'rule-result' -->  
      <!-- Specify the component to execute -->  
      <!-- Define the settings for the component --> 
    </action-definition>
 
  </actions> 
</action-sequence>