Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
372 B
2
Indexable
Never
;with DistinctData AS (
	SELECT DISTINCT
		tt.[TrendName] as TN,
		[User],
		[Time],
		[AssetName]
	FROM 
		dbo.TrendTable as tt
		INNER JOIN 
		dbo.TrendTags as ts
		ON
		tt.TrendName=ts.TrendName
)

SELECT
	TN AS TrendName,
	[User],
	[Time],
	STRING_AGG(AssetName,' , ') as Assets
FROM
	DistinctData
GROUP BY
	TN,[User],[Time]
order by [Time] desc
Leave a Comment