org-ql icon indicating copy to clipboard operation
org-ql copied to clipboard

Aggregate functions in org-ql-query

Open pakelley opened this issue 2 years ago • 2 comments

Is there a simple way to run aggregate functions in :select when using org-ql-query? For example, get a count of all results matching some criteria. I could just count the results with elisp, but it would be nice to have a syntax in org-ql-query that makes things like this concise. If this doesn't exist and it seems like a good idea, I'd be happy to take a swing at implementing it :)

pakelley avatar Feb 02 '23 21:02 pakelley

Hi,

There's nothing like that implemented yet, but it's an interesting idea. You could use simply, e.g. :select t and then wrap org-ql-query in length. Or if you want to be more memory-efficient, you could bind a count variable and increment it in the :select expression.

I'm not necessarily opposed to having a built-in count action, so feel free to propose something. :) Thanks for the suggestion.

alphapapa avatar Feb 07 '23 02:02 alphapapa