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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:59:32+00:00 2026-06-13T05:59:32+00:00

how can i run a SQL query to retrieve weekly and monthly sales reports.

  • 0

how can i run a SQL query to retrieve weekly and monthly sales reports.

Table: orders

ID |Product_id | order price | QTY | purchase date

1        1           34         2        9/10/12
2        1           34         2        8/10/12
3        4           34         2        07/10/12
4        3           34         2        22/09/12
5        1           34         2        9/10/12
6        1           34         2        22/09/12
7        4           34         2        9/08/12
8        3           34         2        22/09/12

Table: Products

ID | Name | description

1    A       ksfjsdkf
2    B       ksfjsdkf
3    C       ksfjsdkf
1    A       ksfjsdkf

Expecting result
:the following is an example result not accurate

product_name           Weekly Sum(QTY), weekly revenue,  Monthly SUM(QTY), monthly revenue

A                           120             3000           2345                  234343
  • 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-13T05:59:33+00:00Added an answer on June 13, 2026 at 5:59 am

    Ok here a simple Query for the Quantities and Order Price

    SELECT p.Description, psw.qtysum, psw.opsum, psm.qtysum, psm.opsum
    FROM Products p
    LEFT JOIN
      ( SELECT sw.product_id, SUM( sw.QTY ) AS qtysum, SUM( sw.`order price` ) AS opsum 
        FROM orders sw 
        WHERE WEEK( sw.`purchase date`) = WEEK( current_date )
        AND YEAR( sw.`purchase date`) = YEAR( current_date )
        GROUP BY sw.product_id ) psw 
      ON p.id = psw.product_id
    
    LEFT JOIN
      ( SELECT sm.product_id, SUM( sm.QTY ) AS qtysum, SUM( sm.`order price` ) AS opsum 
        FROM orders sm 
        WHERE MONTH( sm.`purchase date`) = MONTH( current_date )
        AND YEAR( sm.`purchase date`) = YEAR( current_date )
        GROUP BY sm.product_id ) psm 
      ON p.id = psm.product_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I make a sql SELECT query run forever in oracle 10g? It
how can i write to a mysql table with ruby ? run SQL. for
I want my SQL query can run like this. I have two tables: Key1,
I want to create an android application that can run SQL Query to my
I have a SQL query for a table in which the user can create
Can not run following SQL from ant's sql task : BEGIN DBMS_AQADM.CREATE_QUEUE_TABLE( queue_table =>
Is there a command I can run inside my SQL script so that it
The web applications I am installing can run against either a SQL Server or
In java-jdbc, I can easily run the following SQL (NOTE the double quotes around
I can't run this function. It gives the error: ERROR at line 9: PL/SQL:

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.