-
Notifications
You must be signed in to change notification settings - Fork 346
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
[question] How to group data rows by day from datetime column? #606
Comments
Hi, You are right, IIUC, you want to retrieve all rows but you want rows clustered by start date? That's what ORDER BY cast(start_time AS Date) DESC, end_time DESC -- untested cast syntax That orders by start date and if there were several rows of the same start date it orders by end time. Unfortunately,
Does this help? Best, |
@rbock yes it helps partially. In fact, I did an order by and I think with that data I can already render things the way I want by traversing and grouping the rows and get it done. So thanks for your help, at least it clarified how to go forward. However, and out of curiosity, how could I implement custom functions? I saw some of the code in the repo. I think it would be a great feature to have some class (like boost did for iterator, for example, or like C++ ranges did with https://en.cppreference.com/w/cpp/ranges/view_interface) to help define, in the easiest way, new functions. Why I say this? Because, for example, being able to do this would be really nice:
where By the way, great library! :) EDIT: I think you replied to my question here:
Ok. I won't do it since I do not feel the need right now. But maybe (just maybe, sorry) in the future, I would be interested in making exposing SQL functions in a strongly-typed way easier. That would be a great addition to this library I think. |
Thanks for the great feedback. Adding custom functions isn't super hard, but undocumented. The easiest (IMO) way is to copy an existing function and modify it to do what you need. To create a
Writing a generic
Actually, future is probably better in this case, as I believe that this will become easier with the next major iteration of the library in the optional branch I mentioned above. Cheers, |
When is the next release planned? Feel free to close the issue. It is actually a non-issue anymore after your first comment. |
I hope to get the "optional" branch ready this quarter, but it is more likely to happen in early 2025. I'll leave this open as I might add the |
I have this query:
Which shows this (and more irrelevant data to the right for this case):
I would like to show something like that table, but grouping in table/day, something like this:
But I just do not know how to do it or if it is even possible. I would say I want to use group_by (but that is for aggregates or all data columns must appear in SQL I think...) and I want that the group by
day_of(mt.startTime)
.Is this even possible or makes sense in SQL? I think SQL group_by is for aggregate data actually. The problem I am finding is that I do not know how to group per date day only in sqlpp.
The other problem (SQL-related) is that I do not know even if that is legal in SQL. Maybe with some subquery is possible?
The text was updated successfully, but these errors were encountered: