this question has answer here:
i know in sql server cannot use group_concat
function here 1 issue have in need group_concat
query.i google found logic not able correct it.my sql query is
select m.maskid,m.maskname,m.schoolid,s.schoolname, md.maskdetail tblmask m join school s on s.id = m.schoolid join maskdetails md on m.maskid = md.maskid order m.maskname ;
it gives me result like
just first 3 rows in maskid,maskname,schoolid,schoolname same maskdetail different want 1 row in last column can contain maskdetails per maskid , on.
i want output like
and on.so please me while making query that.
thanks in advance.
query:
select m.maskid , m.maskname , m.schoolid , s.schoolname , maskdetail = stuff(( select ',' + md.maskdetail dbo.maskdetails md m.maskid = md.maskid xml path(''), type).value('.', 'nvarchar(max)'), 1, 1, '') dbo.tblmask m join dbo.school s on s.id = m.schoolid order m.maskname
additional information:
Comments
Post a Comment