Hello, in a `GROUP BY` query I am trying to use so...
# suiteql
v
Hello, in a
GROUP BY
query I am trying to use something equivalent to PostgreSQL’s
string_agg
or Oracle’s
LISTAGG
, I noticed that there is a function
CONCAT
in https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_158513731864.html#SuiteQL-Supported-and-Unsupported-Functions , that could combine the strings but it’s not working for me giving back
Copy code
%{
         "detail" => "Invalid search query. Detailed unprocessed description follows. Search error occurred: Invalid or unsupported search.",
         "o:errorCode" => "INVALID_PARAMETER",
         "o:errorQueryParam" => "q"
       }
(for the record COUNT works), is there a way to combine a resulting list of strings into one? Preferably with a delimeter I can set
Ahh I believe it’s meant to be used with 2 arguments, not group by
I wonder if there is at least something that I could use with group by to create an array of something
s
LISTAGG example. Please note that the maximum concatenated string is 4000 characters.
Copy code
WITH t2 AS (
  SELECT     transaction.id AS transaction_id, transactionline.uniquekey
  FROM       transaction
  INNER JOIN transactionline ON (transactionline.transaction = transaction.id)
  FETCH FIRST 1000 ROWS ONLY
)
SELECT   t2.transaction_id,
         LISTAGG(t2.uniquekey, ', ') WITHIN GROUP (ORDER BY t2.uniquekey) AS transactionline_uniquekeys
FROM     t2
GROUP BY t2.transaction_id
ORDER BY t2.transaction_id
v
Thank you!!! I was so frustrated with this one, just tested it and works like a charm!! ❤️