SQL > Custom Queries
Queries/exports for specific EOs
Stratford Lit [32000]
Top 10 Customers
EO wanted to reward top purchasers for a given year (2025)
sql
SELECT TOP 10 contactName, contactEmail, COUNT(transaction_id) AS numBookings
FROM DBA.event e1
JOIN DBA.venue v1 ON e1.event_id = v1.event_id
JOIN dba.performance p1 ON v1.venue_id = p1.venue_id
JOIN dba.transaction t1 ON p1.performance_id = t1.performance_id
JOIN DBA.patron pat1 ON t1.patron_id = pat1.patron_id
WHERE e1.promoter_id = 32000
AND transactionCategory = 'TICKETS'
AND transactionType = 'DR'
AND transactionDateTime BETWEEN '2025-02-14' AND '2025-11-03'
AND contactName <> 'anon anon'
GROUP BY contactName, contactEmail
ORDER BY numBookings DESC