SELECT 
    bl.name as location_name,
    tp.method,
    COUNT(*) as transaction_count,
    SUM(tp.amount) as total_amount,
    (COUNT(*) * 100.0 / SUM(COUNT(*)) OVER (PARTITION BY bl.id)) as percentage_of_transactions
FROM business_locations bl
JOIN transactions t ON bl.id = t.location_id
JOIN transaction_payments tp ON t.id = tp.transaction_id
WHERE t.type = "sell" AND t.status = "final"
GROUP BY bl.id, bl.name, tp.method
ORDER BY bl.name, transaction_count DESC;