Thanks Jason, for clearing that up for me. I've wondered about that for some time.
The link you suggested above http://www.tizag.com/mysqlTutorial/mysqlsum.php (ps, they have very good tutorails) has the following example that I'm trying to understand how to use...
<?php
// Make a MySQL Connection
$query = "SELECT type, SUM(price) FROM products GROUP BY type";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "Total ". $row['type']. " = $". $row['SUM(price)'];
echo "<br />";
}
?>
Would I put the "SELECT type, SUM(price) FROM products GROUP BY type" in a recordset and then hand code everything under it?
Also, if COUNT & SUM are used in a recordset, how does that help my dilemma of having to many recordsets? Is it because they provide many more results (statistics) with a single recordset?
Because I want to pick & choose what statistics I display, I went searching for a way to stack COUNT statements, I came across this example of code on stackoverflow. but I was able to get it to work (in a recordset) and echo the aliases...
SELECT
SUM(CASE WHEN Mbr_Status = 'Regular' THEN 1 ELSE 0 END) StatusRegular,
SUM(CASE WHEN Mbr_Status = 'App' THEN 1 ELSE 0 END) StatusApplicant,
SUM(CASE WHEN Mbr_Status = 'None' THEN 1 ELSE 0 END) StatusNone,
SUM(CASE WHEN Mbr_Status = 'Club' THEN 1 ELSE 0 END) StatusClub
FROM member_accounts
Does this look like a good (reliable & efficient) statement? I'm asking because I don't have a clue as to what it is doing with the if statements.
Thanks