I need to get the total amount of sales of each artist out of this four tables:
Artists (artist.id, artist.name)
Events (events.id, events.title, events.artist_id)
Sales (sales.events_id, sales.buyer_id, sales.amount)
Buyer (buyer.id, buyer.name)
I need the following statement joining just three tables:
SELECT sales.amount as SalesTotal, artists.title AS Artist
SUM (SalesTotal)
FROM sales
INNER JOIN events ON events.id = sales.event_id
INNER JOIN artists ON artists.id = events.artist_id
GROUP BY Artist
But I get always a Syntax error. I have googled it but all examples I get are inside the same table. I do not get where the error should be. Any help would be appreciated