SQL行转列

SELECT p.KeyId,AttName= (STUFF((SELECT TOP 2 ' ' + item.ItemName FROM Pro_PropertyAttributeRelations pat LEFT JOIN Sys_SysParameterItems item
ON pat.PropertyAttributeKeyId=item.KeyId
WHERE pat.PropertyKeyId=p.KeyId ORDER BY NEWID() FOR
XML PATH('')
), 1, 1, '') )
FROM dbo.Pro_Propertys p
INNER JOIN VW_Adm_B_PushPropertys attr ON p.KeyId=attr.KeyId
GROUP BY p.KeyId

posted on 2019-08-13 13:33  梨窝★浅笑  阅读(91)  评论(0编辑  收藏  举报

导航