I have thousands of users and each user has his or her own 'total post count', how would I go about determining what the average post count is for the average user?
Example:
The Database has a total of 4 users:
User 1 has a total of 2 posts.
User 2 has a total of 5 posts.
User 3 has a total of 8 posts.
User 4 has a total of 9 posts.
To find the average number of posts for the average user, I would take the four user's totals (2, 5, 8, 9), add them together... 24... then divide by the total number of users (4).. which leaves use with the average post count of '6'.
Now as for my database structure... I have a simple 'posts' table that allows the following records:
Code: Select all
CREATE TABLE posts (
post_id INT NOT NULL AUTO_INCREMENT,
user_id INT NOT NULL,
post_text TEXT NOT NULL,
date_added DATETIME NOT NULL,
PRIMARY KEY (post_id)
);