diteps06
asked on
Query that generates the life cycle of product’s orders
I will like to produce a query which generates the life cycle of orders on the different products present in the company.
The order of the products for each item from when it was lunched in the market is available in Table 1. The product can start having orders from when it was lunched or there can be a month where orders were absent (AX1). Another possibility is that the product may start having orders some few months later from it was presented over the market.
The launch dates for each product are present in table 2
I will like to have for each product the monthly order from when it was launched under a common monthly timescale distribution. The monthly distribution is an incremental month distribution from the respective launched date to present date.
Month1 is the launched date each product, Month 2 is the second month from the launched date ( eg. AX1 200810, BY1 200910) and so on. The resultset I am expecting is in Table 3.
How can I achieve it
Product Date Order
AX1 200810 29
AX1 200812 13
AX1 200902 45
BY1 200909 5
BY1 200910 7
BY1 200911 3
BY1 200912 4
CZ1 201111 4
CZ1 201112 6
CZ1 201201 10
Table 1 Storical table of product orders
Product LaunchDate
AX1 200809
BY1 200909
CZ1 201110
Table 2 Launch dates of products
Product Month1 Month2 Month3 Month4
AX1 29 13 45
BY1 5 7 3 4
CZ1 4 6 10
Table 3 Product order's in life cycle
Database: Oracle 10g
The order of the products for each item from when it was lunched in the market is available in Table 1. The product can start having orders from when it was lunched or there can be a month where orders were absent (AX1). Another possibility is that the product may start having orders some few months later from it was presented over the market.
The launch dates for each product are present in table 2
I will like to have for each product the monthly order from when it was launched under a common monthly timescale distribution. The monthly distribution is an incremental month distribution from the respective launched date to present date.
Month1 is the launched date each product, Month 2 is the second month from the launched date ( eg. AX1 200810, BY1 200910) and so on. The resultset I am expecting is in Table 3.
How can I achieve it
Product Date Order
AX1 200810 29
AX1 200812 13
AX1 200902 45
BY1 200909 5
BY1 200910 7
BY1 200911 3
BY1 200912 4
CZ1 201111 4
CZ1 201112 6
CZ1 201201 10
Table 1 Storical table of product orders
Product LaunchDate
AX1 200809
BY1 200909
CZ1 201110
Table 2 Launch dates of products
Product Month1 Month2 Month3 Month4
AX1 29 13 45
BY1 5 7 3 4
CZ1 4 6 10
Table 3 Product order's in life cycle
Database: Oracle 10g
ASKER
There is no problem if there will be more than 40 months. The client is ready to expect it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think some modern reporting tools will do the pivot table.
The query is very good especially the expressions of nature:
SUM ( DECODE (Mthb, 1, Ordernum, 0)) Month1
Thanks
The query is very good especially the expressions of nature:
SUM ( DECODE (Mthb, 1, Ordernum, 0)) Month1
Thanks
MAX(order_date) - MIN(launchdate) = 40 months.
Or do you only want the first 4 months = launch date + 3 months like this:
Open in new window