Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CREATING A SUM COLUMN -- HELP

Status
Not open for further replies.

kingjjx

Programmer
Joined
Sep 18, 2001
Messages
181
Location
US
How can you create a sum column with ColdFusion?
In my database table, I have 3 fields- Exam1, Exam2, Exam3 ...
I created a form that would enable students to submit their scores for Exam1, 2 and 3 .. now I want to create a page where students can see their Exam scores and a 4TH COLUMN which shows the total score of exam 1 to 3 added.

How can I create this 4th column with ColdFusion ?
Please help

thanks
 
Just sum the fields like this:
Code:
select exam1, exam2, exam3, exam1+exam2+exam3 as exam_sum
...
Then use it like this:
Code:
<table>
<cfquery ...>
  <tr>
    <td>#exam1#</td>
    <td>#exam2#</td> 
    <td>#exam3#</td>
    <td>#exam_sum#</td>
  </tr>
</cfquery>
</table>
 
Hey, where do I put the FROM statement ?

SELECT exam1, exam2, exam1+exam2 AS exam_total FROM exam_scores

would that be right ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top