Multiple FROM clauses with subqueries (NRQL)

I’m trying to do the following query. I want to get the ‘acceptCount’ and ‘totalCount’ in a single query.

SELECT acceptCount, totalCount
FROM (FROM Transaction SELECT count(*) as 'acceptCount' WHERE result = 'ACCEPT'), (FROM Transaction SELECT count(*) as 'totalCount') 

However, I am getting the following error.
“Error at line 2 position 81, unexpected ‘,’”

I’ve tried restructuring the query in many forms but the result is still the same.

Any ideas?

Hi, @vbermudez: No need for a subquery. You want to use the filter() function:

SELECT 
  count(*) AS 'totalCount', 
  filter(count(*), WHERE result = 'ACCEPT') AS 'acceptCount'
FROM Transaction
2 Likes

Awesome, thanks! This works.