I am working in a task and got stuck at particular question. I am new to SQL so I am reaching out to this platform for the support. Below are the 2 tables. 1st is Theatre_play_table and 2nd is Ticketsales table. Question: List titles, directors and writers of all shows/plays with the highest total sale.
Theatre_play_table
Ticketsales table
I have pasted screenshot of some part of the table. ID column in both the table represents the same information. Last column in Ticketsales table is Totalamount.
I have tried with below query; Select theatre_play.title, theatre_play.director, theatre_play.writer, sum(totalamount) from theatre_play, totalsales where theatre_play.id = totalsales.id group by theatre_play.title, theatre_play.director, Theatre_play.writer order by sum(totalamount) desc fetch first 3 rows only;
The above approach is not useful when data is huge. I wanted to apply max(sum(totalamount)) but oracle threw an error.
Can anyone please help me solve this question?


play_id) into the subquery and usefetch first 1 rows with ties, which will return all top-sold shows. Then perform a join. If you will provide sample data as text, I will be able to write a query