Home » SQL & PL/SQL » SQL & PL/SQL » Last four weeks data (Oracle 12c)
Last four weeks data [message #639301] Sun, 05 July 2015 18:19 Go to next message
imranhemani
Messages: 1
Registered: July 2015
Junior Member
I have the following tables with their respective data:

FORECAST:
- ITEM
- FORECAST_WEEK_DATE
- FORECAST

SALES:
- ITEM
- WEEK_DATE
- SALES

The WEEK_DATE column has records for every end-of-week date like:
7/02/2015
15/02/2015
and so on.

I want to bring the results from the both the tables so that the result like:

ITEM FORECAST_TOTAL SALES_TOTAL
001 23 45

for the total of latest 4 weeks data.

How do I achieve that ?


Re: Last four weeks data [message #639302 is a reply to message #639301] Sun, 05 July 2015 18:42 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Welcome to this forum.

Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/ and read http://www.orafaq.com/forum/t/174502/

>for the total of latest 4 weeks data.
explain in detail & with examples which dates should be included in the "latest 4 weeks data"

TEST CASE should include data for all possible boundary conditions
Re: Last four weeks data [message #639304 is a reply to message #639301] Mon, 06 July 2015 00:02 Go to previous message
Michel Cadot
Messages: 68643
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Join the tables, use SUM aggregate function and GROUP BY to get the total per item; a WHERE clause is necessary to restrict the result to the last 4 weeks.

Previous Topic: need select query based on pl sql table
Next Topic: want to delete 42k duplicate rows from table 18 mill rows
Goto Forum:
  


Current Time: Tue Apr 23 04:23:41 CDT 2024