MySQL Sum Record Values
Like this blog? Consider exploring one of our sponsored banner ads...
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:
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.
About this entry
You’re currently reading “MySQL Sum Record Values,” an entry on BRADINO
- Published:
- 3.29.07 / 4pm
- Category:
- MySQL
- Tags:
No comments
Jump to comment form | comments rss [?]