[英]How to count total amount of pending tickets monday in oracle-sql?
If each row represents a ticket, then you can get the number that are pending on a particular day using:如果每一行代表一张票,那么您可以使用以下方法获取特定日期待处理的号码:
select count(*)
from t
where updated_at < :date and status = 'pending';
Note: This is not going to count "pending" statuses that were changed to another state.注意:这不会计算更改为另一个 state 的“待定”状态。 This data does not have enough information to answer that.该数据没有足够的信息来回答这个问题。 And your question has not explained the state changes.而且你的问题没有解释 state 的变化。
I would actually suggest that you ask a new question with more comprehensive information about what the states are, how they change as well as sample data and desired results.我实际上建议您提出一个新问题,其中包含有关状态是什么、它们如何变化以及样本数据和期望结果的更全面的信息。
I am assuming that the tickets which are not closed are pending.我假设未关闭的票正在等待处理。 You can use the GROUP BY
and HAVING
as follows:您可以使用GROUP BY
和HAVING
,如下所示:
SELECT COUNT(1) AS PENDING FROM YOUR_TABLE T
WHERE T.CREATED_AT <= <<YOUR_DATE>>
GROUP BY T.TICKET_ID
HAVING SUM(CASE WHEN T.STATUS = 'closed' THEN 1 ELSE 0 END) = 0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.