![](/img/trans.png)
[英]PostgreSQL Select distinct values of comma separated values column excluding subsets
[英]How to have select distinct of all but last column , and last column as comma separated values
在子查詢中選擇不同的7個值,然后執行XML STUFF合並值
請注意“-在這里添加其他字段”
例
Select A.*
,CollectionDate = Stuff((Select Distinct ',' +cast(CollectionDate as varchar(max))
From YourTable
Where Quantity=A.Quantity
and Protein =A.Protein
and Carb =A.Carb
-- Add your other fields here
For XML Path ('')),1,1,'')
From (Select Distinct
Quantity
,Protein
,Carb
-- Add your other fields here
From YourTable ) A
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.