Skip to content
Advertisement

Is there a way to group by part of a datetime column in SQL?

I have a dataframe something like this.

is there a way to return a table that sums the dollar values based on the time down to the minute. For example:

Notice that the “time” data in the original data set spans over a few days but I am only concerned with the time of day.

Thanks

Advertisement

Answer

I’m not sure if there is a way to just extract the time, but you can format it as a string:

Or, you can just convert the value to a time (subject to Piotr’s comment):

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement