The following SQL Server query need help
select 
    JI.id, RBIEnvironment
from
   (select 
       issue,
       case when cfname='RBI-Environment' 
              then customvalue 
             else null 
       end as 'RBIEnvironment' 
    from X) as CT
where 
    CT.issue = JI.id
group by 
    JI.id, RBIEnvironment
The issue is the CT table returns the data in following format
1   NULL
1   STG
1   PROD
2   SIT
2   DIT
3   SIT
Hence the outer query returns
1   NULL
1   STG
1   PROD
2   SIT
2   DIT
3   SIT
I need in following format
1   STG,PROD
2   SIT,DIT
3   SIT
Please use the same inner dynamic table as such as it contains some more columns which needs to be displaye din the resultselt .This inner table is linked with the outer table using the issue field and ID field respectively