What's wrong with this SuiteQL query? It says ther...
# ask-stanley-ai
a
What's wrong with this SuiteQL query? It says there's a syntax error: SELECT T.id as OppId, T.tranid as OppNum, T.entitystatus, LISTAGG (DISTINCT TL.item, ' | ') WITHIN GROUP (ORDER BY TL.id) as OppItems, ForecastingTool.id as FCTid, ForecastingTool.custrecord17 as FCTitemid FROM Transaction T JOIN CUSTOMRECORD121 ForecastingTool ON ForecastingTool.custrecord_fbsg_forecast_linkedopp = T.id JOIN TransactionLine tl ON T.id = tl.transaction WHERE T.type = 'Opprtnty' AND T.entitystatus = 13 AND tl.mainline = 'F' AND tl.taxline = 'F' GROUP BY T.id, T.tranid, T.entitystatus, ForecastingTool.id, ForecastingTool.custrecord17 ORDER BY T.id ASC, ForecastingTool.id ASC, OppLine ASC;
c
AI generated answer (using internal Slack threads):
The issue with your SuiteQL query is that you're trying to use the
LISTAGG
function, which is not supported in SuiteQL. This function is used to aggregate a set of string elements into a single string, but unfortunately, SuiteQL does not support this function. Here is the part of your query that is causing the issue:
Copy code
sql
LISTAGG (DISTINCT TL.item, ' | ') WITHIN GROUP (ORDER BY TL.id) as OppItems
You might need to find an alternative way to achieve the same result without using the
LISTAGG
function. One possible solution could be to fetch the data without aggregation and then process it in your script to achieve the desired result. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.847107053
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.844299436
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.842834473
Please provide your feedback on this answer.
Thank you for your feedback
a
I was working before I removed the linesequencenumber from the SELECT and GROUP BY