Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8940

Count of an order for a day as well as number of times it is routed-alculation

$
0
0

Eg: When an online order is placed, the order is delivered to the customer in some days. For example an order is taking 10 days to deliver to the customer.

Order placed date: Dec 1, 2013

Order shipped/complete date: Dec 5,2013

Delivered Date: Dec 11, 2013

 

For the order to complete, it will travel through many departments.

Dept 1: Invoice

Dept 2: Billing

Dept 3: Process

Dept 4: Shipment

 

Data is stored in table as follows

 

DB Table:
DateOrder #Next_locPrevious_locUser
12/1/2013AAP1Dept1nullUser1
12/1/2013AAP1Dept 2Dept1User1
12/2/2013AAP1Dept 2Dept2User1
12/2/2013AAP1Dept1Dept2User2
12/3/2013AAP1Dept3 Dept1User1
12/3/2013AAP1Dept 2Dept 3User2
12/3/2013AAP1Dept3 Dept2User2
12/4/2013AAP1Dept4Dept3User2
12/5/2013AAP1CompleteDept4User2

 

When an order is placed the order goes through each department. Sometimes, it might go to and fro to the same department.

I have an order placed on Dec 1, 2013. I have following details for the order.

 

So I have to calculate the number of days the order is open, number of days in each dept and also the number of times it is routed to each dept.

If the order is going to the same dept more than one time a day, it is given a count of 1 (In above example on 12/3/2013 order id going to Dept 3 twice but is given a count of 1). For each dept it is going, it will get a count of 1 (On 12/3/2013 order is going to dept 2 and dept 3. So both the depts. Get a count of 1 each for that day).

My report should look like this:

 

Report:
UserOrder #Order Create DateDays OpenDays in Dept 1Days in Dept 2Days in Dept 3Day sin Dept 4Routed to Dept 1Routed to Dept 2Routed to Dept 3Routed to Dept 4Order Complete Date
User 2AAP112/1/201342311232112/5/2013
explanation for the count:order #date placedDiff of (12/5/2013, 12/1/2013)12/1/2013, 12/2/201312/1/2013, 12/3/201312/3/201312/4/201312/1/2013, 12/2/201312/1/2013, 12/2/2013, 12/3/201312/3/2013, 12/3/201312/4/2013

 

 

Can someone please help me in calculating -  Days in each dept as well as Routed to each dept.

 

Appreciate your help.

 

Thanks

Tulasi


Viewing all articles
Browse latest Browse all 8940

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>