SELECT HOUR(t.transaction_date) hour,AVG(tsl.unit_price_before_discount) avg_price,COUNT(t.id) transactions,SUM(t.final_total) revenue FROM transactions t JOIN transaction_sell_lines tsl ON t.id=tsl.transaction_id WHERE t.type="sell" GROUP BY HOUR(t.transaction_date) ORDER BY hour;