Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6730339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:23:49+00:00 2026-05-26T10:23:49+00:00

In my table one of filed is msg. Based this filed two where condition.

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:23:50+00:00Added an answer on May 26, 2026 at 10:23 am
    select telco, 
    sum(
         case when (msg  like '%fatal%' or out_msg like '%exception%' or out_msg like '%fopen%') and a = '1' 
         then 1 else 0 end 
    ) as a,
    sum(
         case when (msg  like '%fatal%' or out_msg like '%exception%' or out_msg like '%fopen%') and a = '2' 
         then 1 else 0 end 
    ) as b,
    sum(
         case when (msg  like '%fatal%' or out_msg like '%exception%' or out_msg like '%fopen%') and a = '3' 
         then 1 else 0 end 
    ) as c,
     sum(
         case when (msg not like '%fatal%' or out_msg not like '%exception%' or out_msg not like '%fopen%') and a = '1' 
         then 1 else 0 end 
    ) as a_e,
    sum(
         case when (msg not like '%fatal%' or out_msg not like '%exception%' or out_msg not like '%fopen%') and a = '2' 
         then 1 else 0 end 
    ) as b_e,
    sum(
         case when (msg not like '%fatal%' or out_msg not like '%exception%' or out_msg not like '%fopen%') and a = '3' 
         then 1 else 0 end 
    ) as c_e
    
    From temp_inbox  group by t
    

    or you can use nested case when insted

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to update a number of records in one table that are based
I have two types of filed one is Required and Other is Not Required.
I have a table with one field that can point to a foreign key
I want to add expire TIMESTAMP in DB table. I have one field timestamp
I have one table view that should be filtered by values of search field
I have one table, t1, which has fileds called userid, week and year fields.
I want to search a table to find all rows where one particular field
I am using SQLite Database and in one my table has field purchased_date (TEXT
In one of the ms-access table I work with we have a text field
Given a table (mytable) containing a numeric field (mynum), how would one go about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.