A | AF | A-217 | 1/1/2013 | 2/3/2013 | 20| 30 A | AF | A-218 | 1/2/2013 | 3/3/2013 | 22| 24 A | AF | A-218 | 1/2/2013 | 3/3/2013 | 22| 34 A | AF | A-219 | 1/2/2013 | 3/3/2013 | 24| 50 B | FF | A-333 | 1/4/2013 | 4/4/2013 | 23| 34 B | FF | A-333 | 1/6/2013 | 5/5/2013 | 34| 78 B | FF | A-335 | 1/6/2013 | 6/6/2013 | 56| 79
These will be grouped by the Code. But the main thing is this: if the ItemID is duplicated within the code (and they will be in order), then only the first instance will have all the columns visible, all the other instances will have only the prodDate and qtyused appearing. The other columns will be blank. For example (the rows with only two values are a date in the proddate column and a value in the QtyUsed column
I noticed some samples using Outer Apply but they had other things that are different from mine so I could not understand if that would be what would be used and if so how it would be used.
The way I plan to do this is to put these initial query results into a temp table and then run a query to select the duplicate lines, tag them, and then update them appropriately. I can do the grouping by the Code field in Chrystal Reports if necessary.
I wonder if this could be done in one query. Thanks for any thoughts on this.