coldfusion - How to Output results based on year from query? -
i have query:
<cfquery name="pivotquery"> select employeedept,cse_name,year,january,february,march,april,may,june,july,august,september,october,november,december ( select month= datename(month,execoffice_date) , year =year(execoffice_date) , employeedept , count(*) 'totalstars' csereduxresponses execoffice_status = 1 group employeedept , month(execoffice_date) , year(execoffice_date) , datename(month,execoffice_date) ) r join csedept d on d.cse_dept = r.employeedept pivot ( sum(totalstars) [month] in ( [january],[february],[march],[april], [may],[june],[july],[august], [september],[october],[november],[december] ) ) pvt </cfquery>
this gets me data want based on month , year. i'm outputing results in table:
<table > <thead> <tr> <th>department</th> <th>january</th> <th>frebruary</th> ......... </tr> </thead> <tbody> <cfoutput query="pivotquery" > <tr> <td>#pivotquery.csedept_name#</td> <td>#pivotquery.january#</td> <td>#pivotquery.february#</td> ....... </tr> </cfoutput> </tbody> </table>
yes outputting data correctly. how can output results in separate table year?
if take @ sqlfiddle, has 2014 , 2015 data. generate separate table each year. data created in sqlfiddle, have 2 tables: 1 2014 , 2015.
depends on how want things displayed. since looks data ordered year should able display year via grouping cfoutput year. like:
<cfoutput query="pivotquery" group="year"> <table > <thead> <tr> <th>department #pivotquery.year#</th> <th>january</th> <th>frebruary</th> ......... </tr> </thead> <tbody> <cfoutput> <tr> <td>#pivotquery.csedept_name#</td> <td>#pivotquery.january#</td> <td>#pivotquery.february#</td> ....... </tr> </cfoutput> </tbody> </table> </cfoutput>
Comments
Post a Comment