简体   繁体   English

仅对列中的特定值求和

[英]Sum Only Specific Values in a Column

I have a query in MS Access that display's the following information:我在 MS Access 中有一个查询,显示以下信息:

ID ID Count数数 Complete_Type Complete_Type
UserA用户A 10 10 Replied已回复
UserA用户A 20 20 Sent发送
UserA用户A 30 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 ID Count数数
UserA用户A 40 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM