Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
413 views
in Technique[技术] by (71.8m points)

coldfusion - How to output table results by using cfoutput group by date?

I have a query that get the all the employees count in a table:

emp_namelast | emp_namefirst | employeetotal | year_cse1
--------------------------------------------------------
smith        | john          | 13            | 2014
smith jr     | jonnny        | 10            |2014
baker        |jane           |5              |2015
doe           |john           |6             |2015

I'm outputting the results in a table. I have the results in order from the query. But with the code below it's outputting the top result from 2014 and then the top result from 2015.

I have tried using no group , which gives me all the data from the query. I would like it to output the data from 2014 and 2015 in two different tables. One would contain records for 2014 and the other 2015.

Would it have to be done without using a 'group'?

<h2>employees</h2>

<table >
    <thead><tr><th>Employee</th><th>Stars</th></tr></thead>
    <tbody> 
        <cfoutput query="GetEmployeeTotals" group="year_cse1">  
            <tr><td>#emp_namefirst# #emp_namelast#</td>
                <td>#employeetotal#</td>
            </tr>   
        </cfoutput>
    </tbody>
</table>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You are on the right track but are missing a detail. The group attribute works like this:

<cfoutput query="somequery" group="somefield">
grouped data goes here

<cfoutput>
ungrouped data goes here
</cfoutput>
grouped data can go here as well
</cfoutput>

In your code, you are not outputting any grouped data, and you are missing the extra cfoutput tags for the ungrouped data.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...