SELECT
    tess_id,
    skycell_id,
    COUNT(*) AS num,
    COUNT(DISTINCT filter) AS num_filter
FROM stackRun
JOIN stackSumSkyfile USING(stack_id)
WHERE stackRun.state = 'full'
    AND stackSumSkyfile.fault = 0
    AND stackSumSkyfile.quality = 0
-- WHERE hook %s
GROUP BY
    tess_id,
    skycell_id
