XF 1.5 Mysql query to find most viewed thread IDs from 2016?

kontrabass

Well-known member
I'm putting together a 'year in review' newsletter and would love to find the most viewed threads with thread creation times within a certain timeframe. Can a mysql guru help me with a query?

Thanks! :love:
 
Code:
SELECT FROM_UNIXTIME(post_date), `thread_id`, `node_id`, `title`, `reply_count`, `view_count`, `user_id`, `username`, `post_date`, `sticky`, `discussion_state`, `discussion_open`, `discussion_type`, `first_post_id`, `first_post_likes`, `last_post_date`, `last_post_id`, `last_post_user_id`, `last_post_username`, `prefix_id`, `tags`
FROM xf_thread
WHERE post_date BETWEEN UNIX_TIMESTAMP('2016-01-01') AND UNIX_TIMESTAMP('2016-12-31')
ORDER BY view_count DESC
 
Code:
SELECT FROM_UNIXTIME(post_date), `thread_id`, `node_id`, `title`, `reply_count`, `view_count`, `user_id`, `username`, `post_date`, `sticky`, `discussion_state`, `discussion_open`, `discussion_type`, `first_post_id`, `first_post_likes`, `last_post_date`, `last_post_id`, `last_post_user_id`, `last_post_username`, `prefix_id`, `tags`
FROM xf_thread
WHERE post_date BETWEEN UNIX_TIMESTAMP('2016-01-01') AND UNIX_TIMESTAMP('2016-12-31')
ORDER BY view_count DESC

Thank you so much, works great!
 
Back
Top Bottom