MS SQL Server 2008.
I have two tables which are joined on the column tra_id.
There are many rows in the PatientInjuries table for each row in the Trauma table.
[tra_id] [int] IDENTITY(1,1) NOT NULL,
[pat_id] [int] NOT NULL,
[pij_id] [int] IDENTITY(1,1) NOT NULL,
[tra_id] [int] NOT NULL,
[icd_ICD] [nvarchar](10) NOT NULL,
I am writing an export where i need one row per tra_id.
So i need to produce all the Trauma columns (easy Trauma.*) plus all the icd_ICD columns for each tra_id.
My problem is i dont know how to join the two tables so that get the many rows in the ProjectInjuries table to appear as columns in the output.
With Trauma as
i need the following:
10, 18929, ABCD, ABC1, FRDA
There are maximum 50 rows in the PatientInjuries table per row in the Trauma table-