Raz*_*t4x 3 sql t-sql ms-access ms-access-2007
我有这个表customerDetail,其中有一个字段c_type,其中"a"代表"active"而"d"代表"not-active".现在我必须在同一查询中找到它们的计数.
我用过这些但没有结果.
SELECT Count(c_type) AS Active, Count(c_type) AS Not_Active
FROM customerDetail
WHERE c_type="a" OR c_type="d"
Run Code Online (Sandbox Code Playgroud)
当然我知道它看起来很脏,但我也尝试了这个,但这也没有用 -
SELECT
Count(customerDetail.c_type) AS Active,
Count(customerDetail_1.c_type) AS Not_Active
FROM customerDetail INNER JOIN customerDetail AS customerDetail_1
ON customerDetail.Id=customerDetail_1.Id
WHERE (customerDetail.c_type="a") AND (customerDetail_1.c_type="d")
Run Code Online (Sandbox Code Playgroud)
但是它也没有用,所以有人可以告诉我,我应该如何知道同一查询中活动和非活动的计数?
select c_type, count(*)
from customer_detail
group by c_type
Run Code Online (Sandbox Code Playgroud)