... INNER JOIN ... WHERE deleted_at IS NOT NULL AND ... ), ... AS ( SELECT ... FROM ... INNER JOIN ... WHERE ... ), ... AS ( SELECT ... FROM ... INNER JOIN ... WHERE ... ) SELECT COUNT(*) OVER ... AS daily_count, IF(week = day, COUNT(*) OVER ..., NULL) AS weekly_count, IF(month = day, COUNT(*) OVER ..., NULL) AS monthly_count, COUNT(DISTINCT user_id) OVER ... AS daily_users, IF(week = day, COUNT(DISTINCT user_id) OVER ..., NULL) AS weekly_users, IF(month = day, COUNT(DISTINCT user_id) OVER ..., NULL) AS monthly_users FROM people_posts INNER JOIN ... w ຊʹϢʔβͷߘʹߜΓࠐΊ͍ͯ Δ͔Θ͔Βͳ͍ w ίϐϖࠈ w ͜ͷ໊લʹΑΓࣾͰղऍ͕όϥ όϥʹͳͬͯ͠·͏ w ྫ w Ϣʔβ͕ϑΟʔυʹߘͨ͠هࣄ w QFPQMFʹදࣔ͞ΕΔهࣄ ϨϏϡʔΛཔΊΔΈ WJFXͰΫΤϦͷ࠶ར༻ੑΛߴΊΔ ΫΤϦ໊ΛࣾͰҰҙʹͳΔΑ͏ʹ