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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:14:41+00:00 2026-06-17T09:14:41+00:00

Rewording my original post for further clarification. I current have the below tables: Product_Ref

  • 0

Rewording my original post for further clarification.

I current have the below tables:

Product_Ref

  • product_id
  • product_name

Products

  • product_id
  • so_date (date)
  • total_sales

Calendar

  • dt (date field, each row representing a single day for the past/next 10 years)

I am looking to produce a report that will tell me the number of products that were sold in the past 6 months (based on SYSDATE) on a daily basis, the report should be every combination of day in the last 6 months against every possible product_id in the format:

Product id | date | total sales

If I assume that there were 0 entries in the products table (i.e no sales) I would still expect a complete report output but instead it would show 6 months of zero’d data i.e.

1 | 2012-01-01 | 0
2 | 2012-01-01 | 0
3 | 2012-01-01 | 0
1 | 2012-01-02 | 0
2 | 2012-01-02 | 0
3 | 2012-01-02 | 0
…

This would assume there were 3 products in the product_reference table – my original query (noted below) was my starter for 10, but not sure where to go from here.

SELECT products.product_id, calendar.dt, products.total_sales
FROM products RIGHT JOIN calendar ON (products.so_date = calendar.dt)
WHERE calendar.dt < SYSDATE AND calendar.dt >= ADD_MONTHS(SYSDATE, -7)+1
ORDER BY calendar.dt ASC, products.product_id DESC;
  • 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-17T09:14:42+00:00Added an answer on June 17, 2026 at 9:14 am

    The clue is in the question – you are looking for a CROSS JOIN.

    SELECT products.product_id, calendar.dt, products.total_sales
    FROM Product_Ref
    CROSS JOIN calendar 
    LEFT JOIN products ON products.so_date = calendar.dt 
                        AND products.product_id = Product_Ref.product_id
    WHERE calendar.dt < SYSDATE AND calendar.dt >= ADD_MONTHS(SYSDATE, -7)+1
    ORDER BY calendar.dt ASC, products.product_id DESC;
    

    I was confused at first by your table names where “Product” in fact means “sale” and “Product_Ref” is a product!

    This is very similar to an example of the use of CROSS JOIN I once posted here.

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

Sidebar

Related Questions

Edit: With enough rewriting, and commenting, I have it running, will post final below
original post: My script is not working (it's not recording the data). It was
**** Sorry for the confusion regarding numCars in the original post. I modified the
Sorry for my original question being unclear, hopefully by rewording I can better explain
My original question regarding Consuming Custom Request Methods with Android seems to have garnered
This is my first post on StackOverflow, so please be gentle... I have some
I have a table recording the amount of data transferred by a given service
I have a view responsible for recording audio. How can i record several audios
I was turned on to nstrees from another question, and have been working through
I have created a voice recording app. It works fine on an iPhone 3G

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.