[英]Sum Only Specific Values in a Column
I have a query in MS Access that display's the following information:我在 MS Access 中有一个查询,显示以下信息:
ID ![]() |
Count![]() |
Complete_Type ![]() |
---|---|---|
UserA![]() |
10 ![]() |
Replied![]() |
UserA![]() |
20 ![]() |
Sent![]() |
UserA![]() |
30 ![]() |
Closed without Response![]() |
I want to create a new SQL query that uses the query above but sum's the count's for each unique user only with Completed Type's "Replied" and "Closed without Response".我想创建一个新的 SQL 查询,该查询使用上面的查询,但总和是每个唯一用户的计数,只有 Completed Type 的“Replied”和“Closed without Response”。 So example, the new query would display this:
例如,新查询将显示如下:
ID ![]() |
Count![]() |
---|---|
UserA![]() |
40 ![]() |
Is anyone able to help me write this query?有人能帮我写这个查询吗?
You can use a where
clause:您可以使用
where
子句:
select id, sum(count)
from t
where Complete_Type in ('Replied', 'Closed without Response')
group by id;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.