Skip to Main Content

SQL Developer

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to Calculate Monthly Sales Contribution to Yearly Sales in SQL?

Mark WilliamsJun 13 2024

Hi everyone,

I have a table named orders with the following columns:

  • orderdate (Date of the order)
  • sales (Sales amount for the order)

I am looking to write a query that will help me calculate the sales at a monthly level and show how each month's sales contribute to the yearly sales as a percentage.

Here's what I'm aiming to achieve in the output:

  • year (The year of the sales)
  • month (The month of the sales)
  • monthly_sales (Total sales for that month)
  • sales_contribution (Contribution of the month's sales to the yearly sales as a percentage)

Could someone help me with the SQL query to achieve this?

Thanks in advance!

Comments
Post Details
Added on Jun 13 2024
3 comments
2,608 views