Query problem

Ok, hello. I’m having some trouble with a query to a database.

Basically the problem is with the data I require. The databse query is something like this:

I need to “concatenate” (I don’t think that’s the specific word for it) the apartment column be one and sum the balance column, so I would get in the query:

Hi.
This is more of SQL question than Wappler question.
You should find learning material on building queries to help you in such scenarios. Stack overflow almost always has something… just need to search with right keywords.

For this case, I am presuming the data is all coming from a single table. This should work.
select building, apartment, group_concat(account, SEPARATOR '&') as 'account', sum(balance) from mytable group by building, apartment

You can use the custom query server action step to get this query to work for you.

With wappler’s query manager I can’t do this kind of queries, right?

Right. Not yet. You have to use Custom Query server action step.
Or, if you can create a view, then you can just use that in the regular DB Query server action step.

What do you mean with “view”? And where do I create it?

:point_up:

Look at this topic. I needed to something like that. I just implemented the recommendations and the solution worked perfectly. Perhaps will helpful and than the will help you.

1 Like

The group_concat is something specific for mysql and is not possible with the query builder, so you will need to use the custom query for that.

The group by and sum are supported by the query builder.

1 Like