【发布时间】:2020-08-16 06:45:30
【问题描述】:
尝试编写查询以检索具有不同月份的数据
预期结果
months12 sev1 sev2
01 1 21
02 1 12
03 0 4
09 1 0
得到结果
months12 sev1 sev2
01 1 21
01 1 12
01 1 4
02 1 21
02 1 12
02 1 4
03 1 21
03 1 12
03 1 4
09 1 21
09 1 12
09 1 4
这里是查询
select DISTINCT months12, sev1, sev2 from
(select Distinct strftime('%m', date(issue_reported)) months12 from tickets),
(select DISTINCT strftime('%m', date(issue_reported)) months, coalesce(count(*), 0) sev1
from tickets where ticket_severity="Sev 1" and strftime('%m', date(issue_reported)) in (select DISTINCT strftime('%m', date(issue_reported)) months from tickets) Group By ticket_severity, strftime('%m', date(issue_reported))),
(select DISTINCT strftime('%m', date(issue_reported)) months1, coalesce(count(*), 0) sev2
from tickets where ticket_severity="Sev 3" and strftime('%m', date(issue_reported)) in (select DISTINCT strftime('%m', date(issue_reported)) months from tickets) Group By ticket_severity, strftime('%m', date(issue_reported)))
【问题讨论】:
-
发布产生这些结果的数据并阐明您想要什么。