簡単に:)これは、最も一般的なDBエンジンで動作するはずです:
select team, count(distinct id) as distinct_id_count_w1, null as distinct_id_count_w2 from myTable where timestamp > t1 and timestamp < t2 group by team
UNION ALL
select team, null as distinct_id_count_w1, count(distinct id) as distinct_id_count_w2 from myTable where timestamp > t2 and timestamp < t3 group by team
枝豆は、あなたがチームごとの結果の両方を読むことをお勧めします、述べたように。それは質問自体から明らかではなかったが、この方法で解決することができる:uは返された結果が異なっていると思われる場合uが唯一の「UNION」で動作するので
SELECT
COALESCE(interval1.team interval2.team) AS team,
interval1.distinct_id_count_w1,
interval2.distinct_id_count_w2
FROM (
select team, count(distinct id) as distinct_id_count_w1 from myTable where timestamp > t1 and timestamp < t2 group by team
) AS interval1
FULL OUTER JOIN
(
select team, count(distinct id) as distinct_id_count_w2 from myTable where timestamp > t2 and timestamp < t3 group by team
) AS interval2
ON interval1.team IS NULL OR interval2.team IS NULL OR interval1.team = interval2.team
結果はチームを使用して参加しません。行の半分にはdistinct_id_count_w2 = Noneがあり、残りの半分にはdistinct_id_count_w1 = Noneがあります。各行は、distinct_id_count_w1の有効な値とdistinct_id_count_w2の有効な値を持つ必要があります – Edamame