-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how can i use function sum() or max() ,or min() something like that , in my request url. #1126
Comments
does postgrest support that ? |
Check the view example in https://postgrest.org/en/v5.0/api.html#horizontal-filtering-rows (search |
i exactly known what you mean, and exactly known how to do .. |
and i found a way to solve the problem by create a function to sum data . and the time range parameter as the function parameter. |
i got a theory : if PostgREST do not support data calculation (like sum, min..) functions in request url, then PostgREST is not able to do any data calculation job without creating functions in sql, it is only able to show data. |
Stored procedure is another option, post a sample of the query you want to achieve to see how it can be done. Edit: posted comment without refreshing the page, nvm. |
To create more complex queries than the ones PostgREST supports out of the box you have to use stored functions, this is explicitly stated in the docs in https://postgrest.org/en/v5.0/api.html#custom-queries. It may be possible in the future to support aggregate functions, see #915 for a discussion on this, but for now this is not possible as we require support for restricting the |
When I create a function as a api . |
i found it already has been added into my header . great !!!! |
Good, considering the issue resolved then. |
@mojinfu I also need this in my project. Could you please tell me how you solved this issue? |
add a special header into http request ,"sorry i cant remember that header name ." and you can get count num in response header. |
but i used prest to do the same thing. prest is more clear and better . i thought. see this https://github.com/prest/prest |
@rrdlpl You could create a view like this: create view employees_summaries as
select
min(salary),
max(salary),
avg(salary)
from employees; And then request it with If the queries are more complicated you could do a similar thing with stored procedures. |
But how we can have this view and be able to filter it for example by date? I don't want to implement all the postgrest features inside my procedure don't want to par all operator to reconstruct the query |
Environment
Description of issue
(Expected behavior vs actual behavior)
(Steps to reproduce: Include a minimal SQL definition plus how you make the request to PostgREST and the response body)
The text was updated successfully, but these errors were encountered: