ステップ 1t1 - where field1is present (つまり、null ではない)のすべての行をカウントし、Count1年と月でグループ化します。
SELECT
Year(t1.date) AS Year,
Month(t1.date) AS Month,
Count(t1.field1) As Count1,
FROM t1
GROUP BY Year(t1.date), Month(t1.date)
ステップ 2t1 -の値t1.field1がNOT IN t2.field1であるすべての行を数え、Count2年と月でグループ化します。
SELECT
Year(t1.date),
Month(t1.date),
Count(*) t1.field1 AS Count2,
FROM t1 LEFT JOIN t2 ON t1.field1 = t2.field1
WHERE ISNULL t2.field1
GROUP BY Year(t1.date), Month(t2.date)
ステップ 3 - 上記の両方のカウントの結果をYear(t1.date)行ヘッダーと列ヘッダーとして表に表示し、各月の下に とMonth(t1.date)の結果をCount1ネストCount2します。
方法がわからないため、手順 3 で表示するコードはありません。