I am using SQL Server database which has tables x.
Table: x
x_id Type Text ID ------------------------------------------- | 1 | Type1 | txt1 | id1 | 2 | Type2 | txt2 | id2 | 3 | Type3 | txt3 | id1 | 4 | Type3 | txt4 | id3 Here, Each ID can have different texts for Type1, Type2, Type 3 ... etc.
I need to generate report which has fields ID, Type1_exists, Type2_exists, Type3_exists, Type1_Text, Type2_Text, Type3_Text where exists columns should say whether ID has that text or not (Y/N). If ID has record which has Type as "Type1" then Type1_exists value should be "Y" otherwise "N".
So, Sample result that I am expecting is
ID Type1_Exists Type1_Text Type2_Exists Type2_Text Type3_Exists Type3_Text --------------------------------------------------------------------- | id1 | Y | txt1 | N | | Y | txt3 | id2 | N | | Y | txt2 | N | | id3 | N | | N | | Y | txt4