GroupBy and Aggregate over date ranges
See original GitHub issueProblem
Need to be able to group and aggregate over ranges of dates (ie. every month, every 2 months, every year, etc)
Suggested solution
Add datetime operators to the groupBy key. Maybe like:
{ groupBy: { dateCol: { 'year': 1 } }
to group by year
or
{ groupBy: { dateCol: { 'month': 2 } }
to group by 2-month intervals
Prisma generate could emit these groupBy interfaces for any column that is a datetime.
Additional context
This was commented as a suggestion last year on the original groupBy issue: https://github.com/prisma/prisma-client-js/issues/1#issuecomment-716578358
But it seems it was ignored and the original issue is now closed 😞
Issue Analytics
- State:
- Created 2 years ago
- Reactions:135
- Comments:25
Top Results From Across the Web
Grouping by date range with pandas - python - Stack Overflow
I'd convert this to a datetime column and then use pd.TimeGrouper : dates = pd.to_datetime(df.date, format='%m-%d-%y') print(dates) 0 ...
Read more >How to group by date time range in pandas? - EasyTweaks.com
Step #2: Aggregate by datetime /timestamp. Aggregating by our date range is relatively simple: performance.groupby ([dates.dt.year]).agg(overall_sales= ...
Read more >How to Group Pandas DataFrame By Date and Time
In this article, we will discuss how to group by a dataframe on the basis of date and time in Pandas. We will...
Read more >Pandas: Groupby to find first dates for each group - w3resource
Pandas Grouping and Aggregating Exercises, Practice and Solution: Write a Pandas program to split the following dataset using group by on ...
Read more >Date range aggregation | Elasticsearch Guide [8.5] | Elastic
A range aggregation that is dedicated for date values. The main difference between this aggregation and the normal range aggregation is that the...
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 FreeTop 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
Top GitHub Comments
This is extremely important. Another usecase: Timeline Chart
I would appreciate this feature too. To make this less abstract I’ll provide a stretch example that’s a good bit beyond what we can do so far. Here’s an example query that I’m currently doing
To fully support this query, Prisma would need
To really add support for grouping by dates, we probably need to handle each one of these tasks or we’re still going to need to do them with raw queries.