Hello team, I'm wondering whether once you have al...
# suiteql
s
Hello team, I'm wondering whether once you have aliased the result of a subquery say in the SELECT statement, it would be possible to reuse that result elsewhere in the query, to avoid running the same subquery twice?
m
I think I've seen on here that people have had success using CTEs in SuiteQL
s
thanks michoel
t
@SimonC You can use the WITH clause, like this:
Copy code
WITH 
	TestEmployee AS (
		SELECT
			ID,
			( LastName || ', ' || FirstName ) AS FullName,
			Phone,
			Email
		FROM
			Employee
		WHERE
			Email LIKE '%@test.com'
	)
SELECT 
	ID, 
	FullName 
FROM 
	TestEmployee
ORDER BY
	FullName
s
Thanks Tim I’ll try it out
w
We are using WITH in a pretty big query. Note that WITH stopped working suddenly this fall. Netsuite fixed it pretty quick though.
s
Thanks for the heads up