You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Does Hasura Engine support groupBy in GraphQL query? #2965
Thanks marionschleifer, sure we can create a view for this purpose. but as I know, groupby can also be integrated into graphql. One example is as below. Do we plan to add this support in future?
@yyuankm1976 The reason why we didn't implement this is because the above approach only works when you want to group by a single column.
Not everyone needs to group data by 2 or 3 columns - I'm trying to build some simple data-visualisation on the UI and it would be a huge blessing if we're able to just group data by even ONE column (with where filters etc)
Activity
marionschleifer commentedon Oct 1, 2019
Hi @yyuankm1976 🙂 it's not possible to use
GROUP BYinside queries. You have to create a view for that: https://docs.hasura.io/1.0/graphql/manual/queries/derived-data.html#step-1-create-a-view.yyuankm1976 commentedon Oct 2, 2019
Thanks marionschleifer, sure we can create a view for this purpose. but as I know, groupby can also be integrated into graphql. One example is as below. Do we plan to add this support in future?
query {
postsConnection(where: {
someField: true,
}) {
groupBy {
authorName {
key
connection {
aggregate {
count
avg {
nb_likes
}
}
}
}
}
}
}
0x777 commentedon Oct 2, 2019
@yyuankm1976 The reason why we didn't implement this is because the above approach only works when you want to group by a single column.
marionschleifer commentedon Oct 4, 2019
@yyuankm1976 I'm closing this issue. Feel free to re-open if you have any additional questions 🙂
nolandg commentedon Apr 28, 2020
Example using a postgres function is here: #3478 (comment)
agam-singsys commentedon May 28, 2021
Find duplicate entries in a column in PostgreSQL graphql hasura?
Mingyang-Li commentedon Mar 19, 2022
Not everyone needs to group data by 2 or 3 columns - I'm trying to build some simple data-visualisation on the UI and it would be a huge blessing if we're able to just group data by even ONE column (with
wherefilters etc)tirumaraiselvan commentedon Apr 7, 2022
Discussion on implementing various workaround are here: #3478
An easy approach is here: #3478 (comment)