<!--% query_episodes = 'WITH
	comment_tallies AS (	
		SELECT 
			eps_id,
			COUNT(eps_id) AS eps_tally
		FROM comments
		GROUP BY eps_id 
	)
	SELECT
        eps.id,
        eps.explicit,
        eps.date, eps.license, eps.title, eps.summary,
        eps.duration, eps.notes, eps.tags,
        hosts.hostid,
        hosts.host, hosts.email, hosts.local_image,
        miniseries.name AS series, miniseries.id AS seriesid,
		COALESCE(comment_tallies.eps_tally,0) AS commentsTally
    FROM eps
        INNER JOIN hosts ON eps.hostid = hosts.hostid
        INNER JOIN miniseries ON eps.series = miniseries.id
		LEFT JOIN comment_tallies ON eps.id = comment_tallies.eps_id
        WHERE eps.date <= date(\'now\')
        ORDER BY eps.id + 0 DESC'
%-->

