В моей таблице одним из полей является msg. На основании этого поданы два условия. Состояние
where msg like '%fatal%' or msg like '%exception%' or msg like '%fopen%'
then Select telco ,
Sum(Case when a= '1' then 1 else 0 end) as a,
Sum(Case when b= '2' then 1 else 0 end) as b,
Sum(Case when c= '3' then 1 else 0 end) as c,
where msg not like '%fatal%' or msg not like '%exception%' or msg not like '%fopen%'
then Select telco ,
Sum(Case when a= '1' then 1 else 0 end) as a_e,
Sum(Case when b= '2' then 1 else 0 end) as b_e,
Sum(Case when c= '3' then 1 else 0 end) as c_e,
From temp_inbox group by t
здесь имя столбца a, b, c
Я хочу написать вышеуказанное требование одним запросом. Если я пишу два запроса на основе двух, где условие, то я получаю результат, но я хочу написать один запрос и показать свой результат следующим образом:
a b c a_e b_e c_e
5 6 7 10 4 10
1 2 7 45 20 2
образец данных:
a b c msg
1 0 0 fatalerror
0 0 3 successed
1 0 0 exception
0 2 0 successful