Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
I have an A table in a warehouse. I want to query the table as follows:
Is it possible to query a subquery? How can I get distinct values and then get them as a string separated by ','?
Solved! Go to Solution.
Hi @amaaiia @can you try putting your select in a CTE:
;with distinctdata
as
(
select distinct field1 from [lakehouse].[schema].[table] where field2='value2'
)
select STRING_AGG(field1, ',') from distinctdata
Hi @amaaiia @can you try putting your select in a CTE:
;with distinctdata
as
(
select distinct field1 from [lakehouse].[schema].[table] where field2='value2'
)
select STRING_AGG(field1, ',') from distinctdata
User | Count |
---|---|
3 | |
2 | |
1 | |
1 | |
1 |
User | Count |
---|---|
12 | |
8 | |
4 | |
3 | |
2 |