order_by aggregated fields don't use filter
See original GitHub issueHello,
I’m having an issue while using order_by
on aggregate fields.
{
author (order_by: {articles_aggregate: { count: desc }}) {
id
name
articles_aggregate(where: $where) {
aggregate {
count
}
}
}
}
It looks like the SQL query doesn’t apply the filter used in the aggregated count on the order_by
count. Am I doing something wrong?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:18
- Comments:20 (1 by maintainers)
Top Results From Across the Web
SQL: How to filter after aggregation? - Stack Overflow
It is very easy to remove values that you don't want aggregated. For instance:
Read more >GROUP BY and FILTER | SQL Tutorial Documentation on data ...
An introduction to the GROUP BY clause and FILTER modifier. GROUP BY enables you to use aggregate functions on groups of data returned...
Read more >The FILTER clause: Selective Aggregates - Modern SQL
The FILTER clause extends aggregate functions (SUM, AVG, COUNT, etc.) with an additional WHERE clause. Databases not supporting FILTER can use CASE within ......
Read more >Aggregating and Grouping Data
Filter and order results of a query based on aggregate functions. ... GROUP BY tells SQL what field or fields we want to...
Read more >Filter, Search, Sort, Aggregate, Joins & More! - YouTube
The Query All Records function is a powerful and flexible function in Xano. It allows you to a wide-range of things when querying...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@rafaelugolini This is currently the expected behavior. The filters used on
*_aggregate
fields in the query are not applied at the top level. For example, you can have such a query:In this case, we wouldn’t know which filter to apply at the top level.
Your use case however is very valid. Maybe we can extend the
order_by
syntax to allow specifying thewhere
clause?Any news on this ?
I am working with custom reports where the filters are quite dynamic and it is not possible to solve my case with views.
Having the possibility to add where filter to the order_by clause like @0x777 mentioned would solve this perfectly.