Hi jamie61880,
SQL has a lot of functions to do various types of things. The
one you probably need to be investigating is the COUNT() function.
e.g.
SELECT COUNT(*)
FROM someTable
A more complex example would be something like:
SELECT COUNT(*)
AS numOfEmployees
FROM employees
WHERE salary > 25000
In any case, what I'm trying to say is that you can get
calculations and perform sums on database data without having to do
it in ColdFusion. The advantage here is that it is a LOT quicker,
because you're calculating things the database was designed to do.
Its also better this way to keep calculations simpler. If you
were using CFC's (which I see you aren't) you could create specific
functions like getItemCount(id=5) which could return the count from
a query which uses this COUNT() function.
Check out this page which is very helpful:
http://www.techonthenet.com/sql/count.php
Good luck,
Mikey.