Modify WordPress SQL Query to pull from within a category

You need to make sure that the $currentcat variable is set before this query runs. This should be the id of the category you want to pull top posts from.

$sql = "SELECT count(mr.post_ID) AS totHits, p.ID, p.post_title FROM $wpdb->posts p 
JOIN {$wpdb->prefix}kf_most_read mr ON mr.post_ID = p.ID 
JOIN {$wpdb->prefix}term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
WHERE mr.hit_ts >= '".(time() - ( 86400 * $period))."' 
AND $wpdb->term_taxonomy.taxonomy = 'category'
AND $wpdb->term_taxonomy.term_id IN ($currentcat)
GROUP BY mr.post_ID ORDER BY totHits DESC, ID ASC LIMIT $limit";