I have two tables:
users table
list of users
stories
list of stories - multiple stories per user
I want to know the average number of stories a user has. (not a specific user, for all users)
Expected results: 2.3 average stories per user
Tried:
select avg(w) from (select count(distinct user_id) as w from stories group by user_id) a; above ran but didn't seem correct
also:
SELECT user_id, ( SELECT COUNT(*) FROM stories w WHERE w.user_id = u.user_id ) as TotalStories FROM user u;
returned average stories for each user, not average for overall
w
) from (select count(distinct user_id) as w from stories group by user_id) a; – jhanifen