SELECT HOUR(t.transaction_date) hour,COUNT(DISTINCT CASE WHEN tsl.line_discount_amount>0 THEN t.id END) promo_transactions,COUNT(DISTINCT CASE WHEN tsl.line_discount_amount=0 THEN t.id END) regular_transactions,AVG(t.final_total) avg_transaction 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;