I am creating a table collaborating a lot of mapped data, but the query result would be far better suited to produce one row per unique ID than it currently is.
For example, I currently have:
UNIQUE ID | ID NAME | SourceName | SourceDate | StoreName | StoreOrder
1 | First | Example 1 | 1990 | Barnes | 1
1 | First | Example 1 | 1990 | Noble | 2
1 | First | Example 2 | 1996 | Barnes | 1
1 | First | Example 2 | 1996 | Noble | 2
2 | Second | Example 1 | 1990 | Barnes | 1
.... And so on ...
Source info and Store info are not related, they are only related through UniqueID.
What would be ideal is:
UNIQUE ID | ID NAME | SourceName1 | SourceDate1 | SourceName2 | SourceDate2 | StoreName1 | StoreOrder1| StoreName2 | StoreOrder2
1 | First | Example 1 | 1990 | Example 2 | 1996 | Barnes | 1 | Noble | 2 |
I know this is a bit of a messy solution, but it is required for further analysis. A single table, single row per unique ID would be perfect, no matter the column names etc.
It would also be great to have the column names dynamically allocated. For example if one ID has 4 stores allocated then there would be StoreName1 through to StoreName4 (Empty data entries would be 0 or NULL).
Does anyone have any suggestions on how to perform this?
Aucun commentaire:
Enregistrer un commentaire