【发布时间】:2014-06-07 07:26:31
【问题描述】:
我正在使用多个子查询在 MS ACCESS 中创建一个表,其中第一个表包含整个集合,其余表基于另一个条件 - 这是我的代码
SELECT a.id,
a.cnt AS Total_Count,
b.cnt AS Income_Count
INTO data
FROM (SELECT id,
Count(*) AS Cnt
FROM test
GROUP BY id) AS a
LEFT JOIN (SELECT id,
Count(*) AS Cnt
FROM test
WHERE inc > 25
GROUP BY id) AS b
ON a.id = b.id;
It works fine. But when I am putting another sub query its not working
SELECT a.id,
a.cnt AS Total_Count,
b,
b.cnt AS Income_Count,
c.cnt AS EXP_Count
INTO data
FROM (SELECT id,
Count(*) AS Cnt
FROM test
GROUP BY id) AS a
LEFT JOIN (SELECT id,
Count(*) AS Cnt
FROM test
WHERE inc > 25
GROUP BY id) AS b
ON a.id = b.id
LEFT JOIN (SELECT id,
Count(*) AS Cnt
FROM test
WHERE exp > 25
GROUP BY id) AS c
ON a.id = c.id;
你能帮我解决这个问题吗?
【问题讨论】:
-
“不工作”是什么意思?空集?您的表格中的值是什么?你期望得到什么结果?