First, read my
article[
^] on when not to use 'distinct'. Then, try giving us the table structure and some sample data so we can try to help you.
Your code (redundantly) requires the user id to be 13 in ALL your subqueries. So of course you only get data for one user ( I guess that's what the other answer means ). You should post your code so that it doesn't contain code that will obviously break it. And, no, we can't rewrite this without knowing the table structure and having some sample data to test against. Ideally, you'll give us some data and tell us the result you are hoping for, so we can make sense of it all.
I think your other issue is you don't alias your tables, so when you say tm_user in a subquery, it's not clear if you mean the local one, or the external one from the main query. you certainly want to filter each subquery by the user id in the main query, or each result will contain the data of ALL your users.
SELECT distinct TM_User.FullName,TM_Profile.profile, TM_User.Report_To,
stuff(( SELECT distinct ', ' + Reference.lookupvalue FROM Reference
join Reference_Skills on Reference.LookupID=Reference_Skills.SkillLookupKey
join TM_UserAttributeValue on Reference_Skills.SkillLookupValue=TM_UserAttributeValue.AttributeValue
join TM_User on TM_UserAttributeValue.TM_UserID=TM_User.TM_UserID
where Reference.lookupkey='Platform' and TM_User.TM_UserID = u.TM_UserId
FOR XML PATH('')
) ,1,2,'') as platfrom,
stuff(( SELECT ', ' + Reference_Skills.SkillLookupValue FROM Reference_Skills
join TM_UserAttributeValue on Reference_Skills.SkillLookupValue=TM_UserAttributeValue.AttributeValue
join TM_User on TM_UserAttributeValue.TM_UserID=TM_User.TM_UserID
where AttributeKeyType ='Skill' and TM_User.TM_UserID = u.TM_UserId
FOR XML PATH('')
) ,1,2,'') as skills,
STUFF( ( SELECT distinct ', ' + project_name FROM project
JOIN task ON project.project_id = task.project_id
JOIN timesheet ON timesheet.task_id = task.task_id
join TM_user on TM_user.TM_UserID=timesheet.user_id
WHERE project.status = 1 and TM_user.TM_UserID = u.TM_UserId
FOR XML PATH ('')
), 1, 2, '') as project,
STUFF( ( SELECT distinct ', ' + task_name FROM task
JOIN project ON project.project_id = task.project_id
JOIN timesheet ON timesheet.task_id = task.task_id
join TM_user on TM_user.TM_UserID=timesheet.user_id
WHERE project.status = 1 and TM_user.TM_UserID = u.TM_UserId
FOR XML PATH ('')
), 1, 2, '') as task_name
FROM TM_User u
join TM_Profile on TM_Profile.ProfileID=TM_User.ProfileID
WHERE TM_User.Is_Active=1
is what I'd try, but it's impossible to really help without the tables and data to work with.