第 1 步t1- 将所有存在的行(即field1不为空)计数为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)
第 2 步t1- 计算值不t1.field1为的所有行,并按年和月分组。 t2.field1Count2
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 步,因为我不知道该怎么做。