Grouping BQL columns

45 views
Skip to first unread message

Oon-Ee Ng

unread,
Feb 14, 2020, 8:32:06 PM2/14/20
to Beancount
I have this query:-

SELECT
    year, month, account, sum(cost(position))
WHERE
    account ~ 'Assets:Banking:Institution:*'
    and joinstr(other_accounts) ~ 'Liabilities:CreditCards'
GROUP BY year, month, account
ORDER BY year, month, account DESC

Works just peachy, and returns 4 columns. Can I merge year and month into one column? So instead of having (2020, 02) followed by (2020, 01) I'd like (2020-02) followed by (2020-01) etc.

Reason is because I'd like to use fava's nifty new 'graph-from-query' feature =)

Oon-Ee Ng

unread,
Feb 24, 2020, 12:05:10 AM2/24/20
to Beancount
Anyone?

Red S

unread,
Feb 24, 2020, 1:45:59 AM2/24/20
to Beancount
Did you try:
 > help targets

Listed there is YMONTH():
SELECT
    YMONTH(date), account, sum(cost(position))

WHERE
    account ~ 'Assets:Banking:Institution:*'
    and joinstr(other_accounts) ~ 'Liabilities:CreditCards'
GROUP BY YMONTH(date), account
ORDER BY YMONTH(date), account DESC



 
On Sunday, February 23, 2020 at 9:05:10 PM UTC-8, Oon-Ee Ng wrote:
Anyone?

Oon-Ee Ng

unread,
Feb 27, 2020, 2:48:21 AM2/27/20
to bean...@googlegroups.com
Thanks, that works! Harder to do for quarters though, but I think that's a bug in one of the other functions, will start a new thread for that!

--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/8912974e-c7a6-4bb9-9fda-fc91dc014b20%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages