Попытка написать запрос для получения данных с разными месяцами
Ожидаемый результат
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)))