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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:03:50+00:00 2026-05-21T17:03:50+00:00

I am working on a query for a report in Oracle 10g. I need

  • 0

I am working on a query for a report in Oracle 10g.

I need to generate a short list of each course along with the number of times they were offered in the past year (including ones that weren’t actually offered).

I created one query

SELECT coursenumber, count(datestart) AS Offered
FROM class
WHERE datestart BETWEEN (sysdate-365) AND sysdate
GROUP BY coursenumber;

Which produces

COURSENUMBER    OFFERED
----           ----------
ST03              2
PD01              1
AY03              2
TB01              4

This query is all correct. However ideally I want it to list those along with COURSENUMBER HY and CS in the left column as well with 0 or null as the OFFERED value. I have a feeling this involves a join of sorts, but so far what I have tried doesn’t produce the classes with nothing offered.

The table normally looks like

REFERENCE_NO DATESTART TIME TIME        EID     ROOMID COURSENUMBER
------------ --------- ---- ---- ---------- ---------- ----
         256 03-MAR-11 0930 1100          2          2 PD01
         257 03-MAY-11 0930 1100         12          7 PD01
         258 18-MAY-11 1230 0100         12          7 PD01
         259 24-OCT-11 1930 2015          6          2 CS01
         260 17-JUN-11 1130 1300          6          4 CS01
         261 25-MAY-11 1900 2000         13          6 HY01
         262 25-MAY-11 1900 2000         13          6 HY01
         263 04-APR-11 0930 1100         13          5 ST03
         264 13-SEP-11 1930 2100          6          4 ST03
         265 05-NOV-11 1930 2100          6          5 ST03
         266 04-FEB-11 1430 1600          6          5 ST03
         267 02-JAN-11 0630 0700         13          1 TB01
         268 01-FEB-11 0630 0700         13          1 TB01
         269 01-MAR-11 0630 0700         13          1 TB01
         270 01-APR-11 0630 0700         13          1 TB01
         271 01-MAY-11 0630 0700         13          1 TB01
         272 14-MAR-11 0830 0915          4          3 AY03
         273 19-APR-11 0930 1015          4          3 AY03
         274 17-JUN-11 0830 0915         14          3 AY03
         275 14-AUG-09 0930 1015         14          3 AY03
         276 03-MAY-09 0830 0915         14          3 AY03
  • 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-21T17:03:51+00:00Added an answer on May 21, 2026 at 5:03 pm

    I think something like this should work for you, by just doing it as a subquery.

    SELECT distinct c.coursenumber, 
           (SELECT COUNT(*)
            FROM class
            WHERE class.coursenumber = c.coursenumber
              AND datestart BETWEEN (sysdate-365) AND sysdate
            ) AS Offered
    FROM class c
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The simple working query, list the number of licenses for each license type: Query:
I'm constructing a SQL query for a business report. I need to have both
I need to generate a ms-word document from a pl/sql query to export a
I have this query that I am working on for a one time report.
I am stuck figuring out a working SQL Query for the fallowing: I need
I'm working on NetBeans, and want to 'auto-generate' a report with JasperReports. Here is
I'm currently working on writing report generators. For one report I need to do
I have below a working query that needs to be simplified. The reason is
Here is the working query: $sql_project_data = SELECT P.project_id, P.project_name, P.project_type, F.professor_first_name, F.professor_last_name, C.course_id
I have this working query: $q = $this->db->query('SELECT u.name FROM users u JOIN user_group

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.