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 8869747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:33:16+00:00 2026-06-14T17:33:16+00:00

I am using Oracle database and I’m having problem to get one result from

  • 0

I am using Oracle database and I’m having problem to get one result from 2 result sets.

I have table CASES

Create table cases (ID varchar(1), date_entered date, sub_category varchar (5));

insert into cases (id, date_entered, sub_category)
values('1', to_date('2012/05/03','yyyy/mm/dd'),'Temp1');
insert into cases (id, date_entered, sub_category)
values('2', to_date('2012/06/01','yyyy/mm/dd'),'Temp2');
insert into cases (id, date_entered, sub_category)
values('3', to_date('2012/03/15','yyyy/mm/dd'),'Temp3');
insert into cases (id, date_entered, sub_category)
values('4', to_date('2012/03/01','yyyy/mm/dd'),'Call1');
insert into cases (id, date_entered, sub_category)
values('5', to_date('2012/03/08','yyyy/mm/dd'),'Call2');
insert into cases (id, date_entered, sub_category)
values('6', to_date('2012/02/20','yyyy/mm/dd'),'Call2');

and need to count records BY SUB CATEGORIES, BY MONTH, where one count includes sub_category: Temp1, Temp2, Temp3 other count includes sub_category: Call1, Call2, Call3

I have made query1:

With skills
    AS 
    ( 
          Select sub_category, 
                 date_entered,
                 extract(MONTH FROM cases.date_entered) as month_entered, 
                 count (*)
          from cases 
          where 
                SUB_CATEGORY IN('Temp1', 'Temp2', 'Temp3')


          group by cases.sub_category, cases.date_entered
          order by to_char(cases.date_entered,'MM')
    )

    select  s.month_entered, 
            count(*)as skill_count
            from skills s

    group by s.month_entered
    ORDER BY CAST(s.month_entered AS INTEGER) ASC

with result:

MONTH_ENTERED   SKILL_COUNT
3               1
5               1
6               1

and query 2:

With training
AS 
( 
      Select sub_category, 
             date_entered,
             extract(MONTH FROM cases.date_entered) as month_entered, 
             count (*)
      from cases 
      where 
            SUB_CATEGORY IN('Call1', 'Call2', 'Call3')


      group by cases.sub_category, cases.date_entered
      order by to_char(cases.date_entered,'MM')
)

select  t.month_entered, 
        count(*)as training_count
        from training t

group by t.month_entered
ORDER BY CAST(t.month_entered AS INTEGER) ASC

with result:

MONTH_ENTERED   TRAINING_COUNT
2                1
3                2

The result that I need from these 2 queries is:

MONTH_ENTERED   SKILL_COUNT  TRAINING_COUNT
    2               0            1
    3               1            2
    5               1            0
    6               1            0

Tried union and left join but nothing gives me this result.

Here is sqlfiddle example http://sqlfiddle.com/#!4/504cd/31.

  • 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-14T17:33:17+00:00Added an answer on June 14, 2026 at 5:33 pm
    SELECT
      EXTRACT(MONTH FROM CASES.DATE_ENTERED) AS MONTH_ENTERED,
      COUNT (CASE WHEN SUB_CATEGORY IN('Temp1', 'Temp2', 'Temp3') THEN 1 END) SKILL_COUNT,
      COUNT (CASE WHEN SUB_CATEGORY IN('Call1', 'Call2', 'Call3') THEN 1 END) TRAINING_COUNT
    FROM CASES
    GROUP BY EXTRACT(MONTH FROM DATE_ENTERED)
    ORDER BY MONTH_ENTERED ASC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: SELECT INTO using Oracle I have one table in my oracle database.
I have a data mart mastered from our OLTP Oracle database using basic Materialized
I am using oracle database.I want to use duplicate rows from a table except
I have an Employees table. I am using Oracle database. Employees Table - Employee_id
Using oracle database. Here's how i think the SQLException happens... Say i have two
I have a PHP application using an Oracle XE database. Whenever I add a
I have a JRuby project that connects to an Oracle database using JDBC via
I have some Java code that connects to an Oracle database using DriverManager.getConnection(). It
I am using oracle database. If have a large transaction to make (700 tables,
I have this new challenge to load ~100M rows from an Oracle database and

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.