Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement AVERAGE(inventory) BQL fucntion #177

Open
dnicolodi opened this issue Jun 15, 2024 · 0 comments
Open

Implement AVERAGE(inventory) BQL fucntion #177

dnicolodi opened this issue Jun 15, 2024 · 0 comments
Labels
feature New feature

Comments

@dnicolodi
Copy link
Collaborator

I'm going through the TODO.md file checking what has been implemented already, what fits with the current vision for beanquery, and what remains to do. There are two entries related to an AVERAGE() or AVG() function that operates on inventories.

The first is an example query:

SELECT
  root_account, AVG(balance)
FROM (
  SELECT
    MAXDEPTH(account, 2) as root_account
    MONTH(date) as month,
    SUM(change) as balance
  WHERE
    date > 2014-01-01
  GROUP BY 
    root_account, 
    month
)
GROUP BY 
  root_account

which should work, except there is no AVG() function. How would an AVG() function work on inventories? I'm not sure a definition where the different commodity components of the inventory are averaged makes much sense, but I cannot think of a better one that is universally useful.

The second is this note:

FIXME: To render holdings at "average cost", e.g. when aggregating by account,
you could provide an "AVERAGE(Inventory)" function that merges an inventory's
lots in the same way that the holdings merge right now. THIS is how to replace
and remove all holdings support.

which I'm not sure I completely understand.

@blais What did you have in mind?

@dnicolodi dnicolodi added the feature New feature label Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

No branches or pull requests

1 participant