I have a table that has a free form text field, ho...
# suiteql
c
I have a table that has a free form text field, however I only want to return the rows which have numeric data (e.g. 23.432, -12.432). How can I do this in SuiteQL?
t
It's tricky, but you might be able to use a CTE and the REGEXP_LIKE function. Something like this...
Copy code
WITH TransactionTemp AS
	(
		SELECT
			TranID,
			Memo,
			CASE
				WHEN REGEXP_LIKE( Memo, '^-?[[:digit:],.]*$')
				THEN 1
				ELSE 0
  				END AS Memo_Is_Numeric
			FROM
				Transaction
			WHERE
				( Type = 'SalesOrd' )
		)
SELECT
	TranID,
	Memo
FROM
	TransactionTemp
WHERE
	( Memo_Is_Numeric = 1 )
🙌 1
In that example, I'm looking for Sales Orders where the value in the Memo field is a number.
The CTE is necessary because of squirrelly things SuiteQL seems to be doing with REGEXP_LIKE.
c
Thanks! I figured it could be solved with regex but my regex skills are limited to copy and pasting from Stack Overflow 😆
t
Same here. Every single time I need a regex I have to dig for it.
c
Aside from being an excellent playground / tester / troubleshooting environment for regex patterns, regex101.com also provides a searchable library for all flavors of patterns
plusone 1
👍 1
t
That's a great resource. Thanks!
1