Group By on rest API [Jun 24]

:raising_hand_man: Cris Acosta asked

Hi Guys!

How I can use group by, “Data Get dbTableRow groupBy /api/v1/db/data/{orgs}/{projectName}/{tableName}/groupby”?

Someone sample?

:raising_hand_man: Cris Acosta replied

Anyone?

:raising_hand_man: wkw replied

Example:

Project Name: Foo

Table Name: Bar

View Name: Bar

/api/v1/db/data/{orgs}/{projectName}/{tableName}/groupby

```bash

curl --request GET \

–url ‘http://localhost:8080/api/v1/db/data/noco/Foo/Bar/groupby?column_name=Title’ \

–header ‘xc-auth: ’

```

/api/v1/db/data/{orgs}/{projectName}/{tableName}/views/{viewName}/groupby

```bash

curl --request GET \

–url ‘http://localhost:8080/api/v1/db/data/noco/Foo/Bar/views/Bar/groupby?column_name=Title’ \

–header ‘xc-auth: ’

```

Result:

```bash

{“list”:[{“count”:2,“Title”:“A”},{“count”:1,“Title”:“B”},{“count”:1,“Title”:“C”}],“pageInfo”:{“totalRows”:4,“page”:1,“pageSize”:25,“isFirstPage”:true,“isLastPage”:true}}

```

image0

:raising_hand_man: Cris Acosta replied

I´m go try!

:raising_hand_man: Cris Acosta replied

Hi! Show only Count and defined column in the group by clause

:raising_hand_man: wkw replied

sorry. wt do u mean?

:raising_hand_man: Cris Acosta replied

I need reproduce this in the Nocodb

SELECT

usu.NomeUser AS nome,

COUNT(cli.CodCliente) AS Total_de_Nome_RazaoSocial

FROM Atendimentos AS ate

INNER JOIN Clientes cli ON ate.CodCliente = cli.CodCliente

INNER JOIN Usuarios usu ON ate.CodAgente = usu.CodUser

WHERE (ate.criadoEm)>=“2022-06-01” And (ate.criadoEm)<=NOW()

GROUP BY cli.CodCliente, usu.NomeUser

:person_tipping_hand: o1lab replied

currently, joins are on primary and foreign key

is that that case in the above query ?

Easier way I feel is, you could create a view for this in your database

and then do metadata-sync on nocodb

:person_tipping_hand: o1lab replied

you get the api

:raising_hand_man: Cris Acosta replied

Hi Olla!

:raising_hand_man: Cris Acosta replied

I made the joins like FK, ok

Autogenerated from discord


Join NocoDB’s community

DiscordTwitterRedditDocs