gjsaturday
Technical User
TB1
id m t w th f
1 0 1 0 1 0
2 1 0 1 0 1
3 0 2 0 0 2
4 2 0 2 0 2
Shipments made on days where <> 0, so id 1 gets shipments on Tuesdays and Thursdays, ids 2 & 4 on Mondays, Wednesdays, & Fridays, and id 3 on Tuesdays & Fridays
tb2
id date in out
1 03/21/2005 0 6
2 03/21/2005 10 5
3 03/21/2005 0 10
4 03/21/2005 30 2
1 03/22/2005 15 6
2 03/22/2005 0 3
3 03/22/2005 20 5
4 03/22/2005 0 8
1 03/23/2005 0 2
2 03/23/2005 12 2
3 03/23/2005 0 3
4 03/23/2005 50 4
1 03/24/2005 13 2
2 03/24/2005 0 2
3 03/24/2005 0 3
4 03/24/2005 0 4
1 03/25/2005 0 2
2 03/25/2005 12 2
3 03/25/2005 10 3
4 03/25/2005 50 4
So with these tables, I want to group the rows of tb2 by the "schedule" of tb1. In other words, for id 1, I want the sum of Tuesday's and Wednesday's values; and the sum of Thursday's, Friday's, and Monday's values, for id 2, I want the sum of Monday's and Tuesday's values; the sum of Wednesday's and Thursday's values; and then just Friday's Values, and so on and so forth.
id m t w th f
1 0 1 0 1 0
2 1 0 1 0 1
3 0 2 0 0 2
4 2 0 2 0 2
Shipments made on days where <> 0, so id 1 gets shipments on Tuesdays and Thursdays, ids 2 & 4 on Mondays, Wednesdays, & Fridays, and id 3 on Tuesdays & Fridays
tb2
id date in out
1 03/21/2005 0 6
2 03/21/2005 10 5
3 03/21/2005 0 10
4 03/21/2005 30 2
1 03/22/2005 15 6
2 03/22/2005 0 3
3 03/22/2005 20 5
4 03/22/2005 0 8
1 03/23/2005 0 2
2 03/23/2005 12 2
3 03/23/2005 0 3
4 03/23/2005 50 4
1 03/24/2005 13 2
2 03/24/2005 0 2
3 03/24/2005 0 3
4 03/24/2005 0 4
1 03/25/2005 0 2
2 03/25/2005 12 2
3 03/25/2005 10 3
4 03/25/2005 50 4
So with these tables, I want to group the rows of tb2 by the "schedule" of tb1. In other words, for id 1, I want the sum of Tuesday's and Wednesday's values; and the sum of Thursday's, Friday's, and Monday's values, for id 2, I want the sum of Monday's and Tuesday's values; the sum of Wednesday's and Thursday's values; and then just Friday's Values, and so on and so forth.