jen
01/20/2022, 10:13 PMREGEXP_COUNT
in NS (Saved Search or SuiteQL)? I need to do a search for something and sort by the number of times a certain word appears.jen
01/20/2022, 10:26 PMjen
01/20/2022, 10:26 PMSELECT LENGTH(REGEXP_REPLACE(REPLACE('here is my <br/> string with lots of <br/> breaks in<br/>it','<br/>','|'), '[^|]', '')) AS numlinebreaks
jen
01/20/2022, 11:20 PMdescription
of line items.jen
01/20/2022, 11:20 PM\n
, <br>
, <br />
, etcjen
01/20/2022, 11:21 PMjen
01/20/2022, 11:21 PMjen
01/21/2022, 12:19 AMjen
01/21/2022, 12:19 AM"SELECT it.displayname,
AVG(LENGTH(REGEXP_REPLACE(REPLACE(tl.memo,'
','|'), '[^|]', ''))) AS average_linebreak_count,
MAX(LENGTH(REGEXP_REPLACE(REPLACE(tl.memo,'
','|'), '[^|]', ''))) AS max_linebreak_count
FROM transactions tx
JOIN transaction_lines tl ON tl.transaction_id = tx.transaction_id
JOIN items it ON it.item_id = tl.item_id
WHERE
tx.transaction_type = 'Sales Order'
AND tx.trandate > '2020-12-31'
AND tl.memo LIKE '%
%'
GROUP BY it.displayname
ORDER BY AVG(LENGTH(REGEXP_REPLACE(REPLACE(tl.memo,'
','|'), '[^|]', ''))) DESC"