ProCom
Well-known member
I'd love to have these two queries (that I've scavenged together from great threads here) into one query.
Basically: Number of posts and number of likes per user for the past 30 days:
UserID, Username, #_Posts, #_Likes_Received
Here is the first query:
... and the second:
Both of those work individually for the data over the past 30 days, but I'd love to combine both data points on one line per user.
Thanks in advance you master queriers!!!
Basically: Number of posts and number of likes per user for the past 30 days:
UserID, Username, #_Posts, #_Likes_Received
Here is the first query:
Code:
SELECT u.username AS username, COUNT(*) AS totalPosts
FROM xf_post AS p
LEFT JOIN xf_user AS u ON (u.user_id = p.user_id)
WHERE post_date > UNIX_TIMESTAMP(DATE_ADD(NOW(), INTERVAL -30 DAY))
GROUP BY p.user_id
ORDER BY totalPosts
DESC;
... and the second:
Code:
select u.username, count(like_id) as like_count
from xf_liked_content l
inner join xf_user u on (u.user_id = l.content_user_id)
where like_date > UNIX_TIMESTAMP(DATE_ADD(NOW(), INTERVAL -30 DAY))
group by content_user_id
order by like_count desc
Both of those work individually for the data over the past 30 days, but I'd love to combine both data points on one line per user.
Thanks in advance you master queriers!!!