I have two sets of data. The first one looks like this
and the second looks like this
I need to match these two sets on the matching code (in this case 2E5021-1APX) and then in date order (so 2014-11-03 will match 2014-11-07, 11-10 will match 11-25 and so on). I have thought I could perhaps use a cursor to step thru or a forward only recordset to match on min date with the last used date dropping off after each match, but I was hoping to find a better solution. The problem I have right now is when I join these two record sets, rather than getting a combined three records, they cross multiply and I get 9 results since I can't match on date. I am hoping what I am looking for is clear, what I am hoping to get in the end is
where right now I am getting
Thanks,
willie
Code:
2E5021-1APX DOOR-ASSY HEADREST 10340507 70 EA 2014-11-03 00:00:00.000
2E5021-1APX DOOR-ASSY HEADREST 10340507 70 EA 2014-11-10 00:00:00.000
2E5021-1APX DOOR-ASSY HEADREST 10340507 70 EA 2014-12-02 00:00:00.000
and the second looks like this
Code:
2E5021-1APX CUSHION & COVER ASSY FG 2014-11-07 00:00:00.000 2014-12-19
2E5021-1APX CUSHION & COVER ASSY FG 2014-11-25 00:00:00.000 2014-12-23
2E5021-1APX CUSHION & COVER ASSY FG 2014-12-05 00:00:00.000 2014-12-24
I need to match these two sets on the matching code (in this case 2E5021-1APX) and then in date order (so 2014-11-03 will match 2014-11-07, 11-10 will match 11-25 and so on). I have thought I could perhaps use a cursor to step thru or a forward only recordset to match on min date with the last used date dropping off after each match, but I was hoping to find a better solution. The problem I have right now is when I join these two record sets, rather than getting a combined three records, they cross multiply and I get 9 results since I can't match on date. I am hoping what I am looking for is clear, what I am hoping to get in the end is
Code:
2E5021-1APX DOOR-ASSY HEADREST 10340507 70 EA 2014-11-03 00:00:00.000 2014-12-19
2E5021-1APX DOOR-ASSY HEADREST 10340507 70 EA 2014-11-10 00:00:00.000 2014-12-23
2E5021-1APX DOOR-ASSY HEADREST 10340507 70 EA 2014-12-02 00:00:00.000 2014-12-24
where right now I am getting
Code:
2E5021-1APX DOOR-ASSY HEADREST 10340507 70 EA 2014-11-03 00:00:00.000 2014-12-19
2E5021-1APX DOOR-ASSY HEADREST 10340507 70 EA 2014-11-10 00:00:00.000 2014-12-19
2E5021-1APX DOOR-ASSY HEADREST 10340507 70 EA 2014-12-02 00:00:00.000 2014-12-19
[2E5021-1APX DOOR-ASSY HEADREST 10340507 70 EA 2014-11-03 00:00:00.000 2014-12-23
2E5021-1APX DOOR-ASSY HEADREST 10340507 70 EA 2014-11-10 00:00:00.000 2014-12-23
2E5021-1APX DOOR-ASSY HEADREST 10340507 70 EA 2014-12-02 00:00:00.000 2014-12-23
2E5021-1APX DOOR-ASSY HEADREST 10340507 70 EA 2014-11-03 00:00:00.000 2014-12-24
2E5021-1APX DOOR-ASSY HEADREST 10340507 70 EA 2014-11-10 00:00:00.000 2014-12-24
2E5021-1APX DOOR-ASSY HEADREST 10340507 70 EA 2014-12-02 00:00:00.000 2014-12-24
Thanks,
willie