Click here to Skip to main content
15,888,096 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
SQL
select TM_UserAttributeValue.TM_UserID,TM_User.FullName,Reference.LookupID,Reference_Skills.SkillLookupKey,Reference.LookupValue as Platfrom,
 Reference_Skills.SkillLookupValue as skills
  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 AttributeKeyType ='Skill' and TM_UserAttributeValue.TM_UserID=106


the result should be like this
platform skills
.net ASP.NET 2010,c# 3.0
software tes qa, manual
Posted
Updated 24-Sep-13 1:25am
v3
Comments
Member 10256268 24-Sep-13 7:18am    
the result should be like this
platform skills
.net ASP.NET 2010,c# 3.0
software tes qa, manual
Maciej Los 24-Sep-13 7:21am    
Improve question instead using comment.
Maciej Los 24-Sep-13 7:24am    
Where is a problem?
Member 10256268 24-Sep-13 7:26am    
no problem in this code ,i should get platform followed by skills with comma
Member 10256268 24-Sep-13 7:27am    
u see above result ,i should get result like that

1 solution

Ok, the full solution:

select	u.TM_UserID,
	u.FullName,
	r.LookupValue as Platfrom,
	STUFF((
		SELECT	', ' + xrs.SkillLookupValue
		FROM	Reference_Skills xrs
			join TM_UserAttributeValue xua on xua.AttributeValue = xrs.SkillLookupValue
		WHERE	xrs.SkillLookupKey = r.LookupID
			and xua.AttributeKeyType = ua.AttributeKeyType
			and xua.TM_UserID = u.TM_UserID
		FOR XML PATH('')
	) ,1,2,'') as skills
from	TM_User u
	join TM_UserAttributeValue ua on ua.TM_UserID = u.TM_UserID and ua.AttributeKeyType = 'Skill'
	join Reference_Skills rs on rs.SkillLookupValue = ua.AttributeValue
	join Reference r on r.LookupID = rs.SkillLookupKey
where	u.TM_UserID = 106
group by r.LookupID, r.LookupValue, u.TM_UserID, u.FullName, ua.AttributeKeyType
 
Share this answer
 
v4
Comments
Maciej Los 24-Sep-13 9:09am    
Good answer!
+5!
Kirill Borunov 24-Sep-13 9:36am    
thank you ;)
Member 10256268 24-Sep-13 9:14am    
can u add TM_User,fullname column to above code
Kirill Borunov 24-Sep-13 9:31am    
added ;)
Member 10256268 25-Sep-13 8:20am    
Thank u so much kirill

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900