• ScottPletcher - Tuesday, December 19, 2017 11:19 AM

    Not 100% sure what you need, but, for example, this gives sales for the latest quarter for >=7AM and <8AM:


    select *
    from TicketItem
    where s_item IN('Coffee', 'Espresso', 'Double Espresso', 'Decaf Espresso', 'Cappucino', 'Latte', 'Iced Coffee', 'sm coffee pot', 'lg coffee pot')
      and dt_when >= dateadd(quarter, datediff(quarter, 0, getdate()), 0)
      and hour(dt_when) = 7

    Msg 195, Level 15, State 10, Line 15
    'hour' is not a recognized built-in function name.

    Ideas?