Create a new table as required then create an UPDATE query to update the new table from the old one. The update field for the SPUR_A field will look something like [OLD_TABLE_NAME]![SPUR] with the CRITERIA field set to A. Then do the same for the SPUR_B field with the criterai set to B. This will update the new table with the old data.
As long as you realize that you're going to create updating headaches for yourself if this is to become your new datasource, and bloat problems if these are temporary tables.
You can do the exact same thing as SMG suggested, but with normal SELECT queries, and still have your original data intact and no particular bloating problems. If you need to analyze the data in a particular way, try suggesting this (including a demonstration of how the database size changes if you put in new tables like your boss suggested).
If you're in charge of DB design, then your boss should leave that to you, in a perfect world.
I suppose that depends on whether you need the data editable or not. Since you were going to pull it into a new table anyway, I'm going to guess "not".
Option 1:
Use a Crosstab Query (you can do this in design view or with the crosstab wizard).
Base it on your table, we'll call it tableSpurCodes.
Row Heading: PCD, Group By
Column Heading: Spur, Group By
Value: Code, First
(if you use the wizard, it will do all of this for you except that you'll have to uncheck the box "Yes, sum the rows for me").
QueryAll:
Tables: Your main table (the one with PCD as a Primary Key, not tableSpurCodes), plus Query_A and Query_B.
Fields:
PCD (from tablePCDs)
Spur_A, Code_A (from Query_A)
Spur_B, Code_B (from Query_B)
Then it will look exactly like you have above. The drawback of this method is it requires reworking your query if you ever gain new spur codes (C, D, etc).
It will also not be updateable, but if you're just looking to analyze the data from here that won't matter...
Good luck,
David R
[This message has been edited by David R (edited 05-21-2002).]
Thanks David. I managed to get option 1 to work OK.
However Option 2 only works for records that have an A and B record for the same PCD value. Hence records with single A's and B's dont appear in the QueryAll query. I can solve the problem by creating 3 make-table queries (for A's and B's, A's only and B's only) and amalgamating them together.
[This message has been edited by aziz rasul (edited 05-23-2002).]
[This message has been edited by aziz rasul (edited 05-23-2002).]
Option 2 will work for all records, if you change the joins between the tables/queries to LEFT JOINS.
Click on the two relationships (PCD-PCD in Query_A, PCD-PCD in Query_B) and change to the second option, "Include ALL values of tablePCDs and only those values..."
Again, I urge you not to use make-table queries if you can avoid it.
[This message has been edited by David R (edited 05-23-2002).]