In my table one of filed is msg. Based this filed two where condition. The condition are
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
here a, b ,c column name
I want to write the above requirement one query. If i write two query based two where condition then i get result but i want to write single query and show my result in the following way :
a b c a_e b_e c_e
5 6 7 10 4 10
1 2 7 45 20 2
sample data:
a b c msg
1 0 0 fatalerror
0 0 3 successed
1 0 0 exception
0 2 0 successful
or you can use nested case when insted