Creating views in database using Group By

Hi all,

I am new to the bubble world so I hope that the question is not too stupid. I couldn’t find an answer so far tho. I want to create a view in the database which in SQL would be expressed as such:

SELECT category, sum(amount) as sum
FROM table1
GROUP BY category

The views I am currently able to create let me only make data constraints and show selected columns, but I am unable to express the agg. function directly in the database.

I am aware that the desired effect can easily be recreated in the front end and the data then pushed back to the database, but I assume that for security and performance reasons it is a better way to do it in the back end.

Many thanks for your expertise!

Hello! lets see the table first:

“do a search for” with the main query, and then passing the “grouped by” method.

First we group by “category”

then do an “aggregation” like “sum” with “amount”

Resulting:

image

You can see inside editor too:

Original Bubble documentation with Grouped By: Operators & Comparisons - Bubble Docs

Thank you for the quick answer!

This is the method in the front end, which I can work with right now (:

I am curious if it would be possible to transform this table:

image

into this one:


(with position being a list of position)

without having to move to the front end?

I assume that the performance might be better if the calculation is done in the back-end.

i don’t think it’s possible, you could possibly have to have this table with the items already related since creation, but I’ve always used it with large tables, eccommerce lists, contacts, etc. and it’s as quick as a consultation.

from docs

Okay I understand. It is great that that the groupings don’t include much information. I can imagine, that the bubble software does the calculation in it’s own back-end thus me as a developer don’t have to worry about it at all :+1:t5: Many thanks!