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

  • SEARCH
  • Home
  • 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 7809761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:32:21+00:00 2026-06-02T03:32:21+00:00

I have table: STATUS DEFECT DATE CLOSED IP 01.01.2012 CLOSED TV 03.03.2012 CLOSED ADSL

  • 0

I have table:

STATUS  DEFECT   DATE

CLOSED  IP       01.01.2012 
CLOSED  TV       03.03.2012
CLOSED  ADSL     05.05.2012
CLOSED  ADSL     11.01.2012 
CLOSED  TV       15.01.2012
NEW     TV         
NEW     TV

I want to group this by months with count for each specific DEFECT. Status which is considered is CLOSED

Resulting table I would like to be:

MONTH     TV  ADSL  IP
January   1   1     1
March     1   0     0
May       0   1     0

I am using db2 database so the part for displaying months which works is:

select case month(timestamp_iso(DATE))
        when 1 then 'January'
        when 2 then 'February'
        when 3 then 'March'
        when 4 then 'April'
        when 5 then 'May'
        when 6 then 'Jun'
        when 7 then 'July'
        when 8 then 'August'
        when 9 then 'September' 
        when 10 then 'October'
        when 11 then 'November'
        when 12 then 'December'
    end as Month

from TABLE
where  STATUS='CLOSED'
group by month(timestamp_iso(DATE))
order by month(timestamp_iso(DATE))

So I just need to add this part for counting.Thanks

  • 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-06-02T03:32:22+00:00Added an answer on June 2, 2026 at 3:32 am

    You might count defect categories using another case statement that would restrict count to defects in one category:

    select case month(timestamp_iso(DATE))
            when 1 then 'January'
            when 2 then 'February'
            when 3 then 'March'
            when 4 then 'April'
            when 5 then 'May'
            when 6 then 'Jun'
            when 7 then 'July'
            when 8 then 'August'
            when 9 then 'September' 
            when 10 then 'October'
            when 11 then 'November'
            when 12 then 'December'
        end as Month,
        count (case when defect = 'TV' then 1 end) TV,
        count (case when defect = 'ADSL' then 1 end) ADSL,
        count (case when defect = 'IP' then 1 end) IP
    from TABLE
    where  STATUS='CLOSED'
    group by month(timestamp_iso(DATE))
    order by month(timestamp_iso(DATE))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two table emptable1(empid,status) emptable2(empid,week) i want to select all the empid whose
I have following table Id | Status | date ------------------- 1 | Onsite |2007
I have the following table in my postgreSQL 8.3.14 database timestamp status 2012-03-12 19:15:01
I have a little problem in updating date. My first table is DONOR donor-nic----username-----status
I have a simple table structure where each item row has a status. What
I have an Oracle table with data that looks like this: ID BATCH STATUS
I want which order have different order status, so I have a table called
i have a table column called status - data type is boolean. i want
I have one image table and image view status table. In each click of
I have the following table fieldid STATUS CreatedWhen 122 Down 2012-05-16 14:26:56.263 122 Down

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.