Allow function results in group by
See original GitHub issueAllow grouping by function result. This is especially useful with datetime fields. A simple example from postgresql :
SELECT EXTRACT(YEAR from date_column) FROM sales group by EXTRACT(YEAR from date_column)
You can see how this is useful when creating for example yearly, monthly or daily sales results. Without this functionality you need to denormalize your table so year , month and day stays in separate columns.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
SQL GROUP BY and HAVING Clause with Examples - Guru99
The GROUP BY clause is a SQL command that is used to group rows that have the same values. The GROUP BY clause...
Read more >Why Aren't SQL Window Functions Allowed in GROUP BY?
It's true – the SQL order of operations means window functions aren't allowed in GROUP BY. But you can use them anyway with...
Read more >SQL GROUP BY - Everything You Need To Know - Sisense
Group by is one of the most frequently used SQL clauses. It allows you to collapse a field into its distinct values.
Read more >SQL GROUP BY and HAVING: The Complete Guide
The GROUP BY clause is a clause in the SELECT statement. It allows you to create groups of rows that have the same...
Read more >SQL GROUP BY to Summarize and Rollup Query Results
To filter the GROUP BY results, you must use the HAVING clause after the GROUP BY. The GROUP BY statement is often used...
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
OK, this should be a new feature
I could also add code for
ProductModel
andDistrict
but I think it is not important as those fields do not play any role here. And trying to use annotation does not work as well:tortoise.exceptions.FieldError: Unknown field "year" for model "Sales"