BAQ: Calculated Field Concatenate Rows to single field

I’m still getting the same error when trying to use a CTE:

Errors in subqueries definition
Subquery CustomerAttributes can contain Order By clause only in CTE or inner subquery group and with TOP or OFFSET clause specified for it. To sort overall query results specify sorting in TopLevel subquery

1 Like

Can you see if this EpicCare article is helpful for you?
KB0039364 - Turn Multiple Row Values from a Query into a Comma Separated List

3 Likes

2 posts were split to a new topic: BAQ Help

When I import this and run it, I get “Severity: Error, Text: Bad SQL statement.”

Do you know what version of SQL server are you running? Also what version level is your database set to?

I don’t know. How would I find that information?

New query sql

select @@version for the sql server…

The second part I am not sure…is it compatibility level ? (db properties/options )

The reason I ask is String_Agg is supported by, “SQL Server 2017 (14.x) and later”.

STRING_AGG (Transact-SQL) - SQL Server | Microsoft Learn

3 Likes

A cool feature of this function I just discovered - if you want to alphabetize your aggregate results, add “WITHIN GROUP (ORDER BY [field])” after calling STRING_AGG.

For example, to alphabetize and concatenate values from PriceLst with a comma, you’d use:
STRING_AGG(PriceLst.ListCode,',') WITHIN GROUP (ORDER BY PriceLst.ListCode)

1 Like

Hi Jose, i’ve already trying your BAQ, but it turns out an error ‘A generic error occurred in GDI+.’ i couldn’t fix mw issue.

Need help, thank you.

That occurs when you try to bring too much data back to the screen, like a crap ton of large character fields.

Hello Kevin, Thanks for the answer, but i’ve already put the criteria for just 1 part. How can this error possible?

I don’t know, but that’s a local error, not one from the baq itself.

You can show us what you got.