Skip to content
Advertisement

SQL Calculating Hourly Sales

I am trying to create a SQL report that shows hourly sales. This is from my POS system.

There’s a built in table that has basically all the data I need, I’m just struggling to calculate the sum of a column if they are in the same hour.

Table vRPTHourlySalesPerformance (stripped down to only show relevant info):

dt_when create_hour_ordinal c_ticketitem_net_price
2022-11-07 11:20 11 16.00
2022-11-07 12:20 11 17.00
2022-11-07 13:20 12 18.00

I’m looking for a way to output the following.

Hour Total Sales
11 33.00
12 18.00

This is as far as I’ve gotten:

Advertisement

Answer

It appears you are after a simple aggregate:

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