简体   繁体   中英

Sum Only Specific Values in a Column

I have a query in MS Access that display's the following information:

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". 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:

select id, sum(count)
from t
where Complete_Type in ('Replied', 'Closed without Response')
group by id;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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