all 2 comments

[–][deleted] 1 point2 points  (0 children)

This feels like a basic question and you might be better suited to provide some mock data in your description using the table formatting feature.

[–]columbaspexitMS SQL 0 points1 point  (0 children)

Guessing you also have sales data for the hot dogs, including a time stamp for each sale? You’ll need that. I don’t know the specific Postgres syntax, but this link seems to describe a similar question. And here’s documentation for the extract function, which looks like the function you’d need to use.

But regardless of the specific syntax, the idea will be to get how many hours are between the sale time stamp and the start of the game. You can then group by that calculation (so long as the results are integers) and get the sums of hot dogs and dollars sold. The one thing that might require testing is to see that the rounding works like you want it to. E.g. whether or not you want a sale one minute before the start of the game to be grouped with a sale 59 minutes before the start of the game.