MySQL Sum Record Values
In this post I will show you an easy way to group and sum values in records. The most trivial example would be when you have a table of address records and you want to count how many people are from each state:
SQL:
-
SELECT `state`, count( `state` ) AS num FROM `records` GROUP BY `state` ORDER BY `num` DESC
You could use a similar syntax to sum the distinct values in any field and count them.
Home | MySQL | MySQL Sum Record Values
You’re currently reading “ MySQL Sum Record Values ,” an entry on BRADINO
- Published:
- 3.29.07 / 4pm
- Category:
- MySQL












