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

How can I use the cubes and sum a json column? #505

Open
matheusbento opened this issue Dec 14, 2022 · 0 comments
Open

How can I use the cubes and sum a json column? #505

matheusbento opened this issue Dec 14, 2022 · 0 comments

Comments

@matheusbento
Copy link

matheusbento commented Dec 14, 2022

Hello guys, I'm working with Postgresql + Cubes.

I have a JSONB column, which is a array of numbers. how can I modify the cubes to accept the sum of this pattern?

image

I already found a way to do the SUM in the SQL:

SELECT index
    , (SELECT sum(nr::numeric) FROM jsonb_array_elements(snx_wavelengths) nr) AS wavelength_sum
FROM   tbl
ORDER  BY 1;

but I don't know how to implement this part in existent code:
(SELECT sum(nr::numeric) FROM jsonb_array_elements(snx_wavelengths) nr) AS wavelength_sum

I already tried to put the SQL direct on the functions, but no success.

image

In the future, I would like to create new functions like avg, standard deviation, etc..

Anyone can give me some path how to do that?

@Stiivi @pktippa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant