I’m not really sure how to describe this problem without an example, so here’s an example:
I have three tables:
Table 1: Boxes
BoxID | Box Name | Box Cost
1 | Bob's Box | $20
2 | Matt's Box | $21
3 | Jacob's Box | $22
4 | Beth's Box | $23
5 | Rachel's Box | $24
Table 2: Box_ProcessIDs
BoxID | ParentProcessID
1 | 123
2 | 456
3 | 789
4 | 012
5 | 234
Table 3: Box_Processes
ParentProcess | ChildProcess | Start Time | End Time | ProcessName
123 | AAA | 1:00 | 1:05 | Invoiced
123 | AAB | 1:30 | 1:35 | Packed
123 | BBB | 2:00 | 2:05 | Shipped
456 | CDD | 3:15 | 3:20 | Invoiced
456 | DDD | 3:25 | 3:30 | Packaging_Complete
456 | CCD | 3:35 | 3:40 | Shipped
789 | EEE | 4:15 | 4:20 | Invoiced
789 | EEF | 4:25 | 4:30 | Done_Packing
789 | EFF | 4:35 | 4:40 | Shipped
I want the output columns to be:
Box Name, Box Cost, Box Shipping Duration, Box Packing Duration, Box Invoice Duration
I know I can use like %pack% to select my packing fields, and I can figure out how to use Date_Part or somesuch to get my durations, but I’m at a loss as to how to get my shipping duration, packing duration, and invoice duration into separate fields.
So you want to do something like this pseudo-sql?
(will need null checks, proper datetime handling, better names and so on)