You are given two tables describing theater plays and

You are given two tables describing theater plays and reservations for these plays in specific theaters. create table plays(

2. Given: plays: id title writer 34 The opera of the phantom Lero Gastonx 5 The legend of the cake 36 Stone swords Oscar Glad


Transcribed Image Text:

You are given two tables describing theater plays and reservations for these plays in specific theaters. create table plays id integer not null, title varchar (40) not null, writer varchar ( 40 ) not null, unique (id) create table reservations id integer not null, play_id integer not null, number_of tickets integer not null, theater varchar ( 40) not null, unique (id) Write an SQL query that counts the total number of tickets reserved for each play. The table of results should contain three columns: id (id of play), title (title of play) and reserved_tickets (total number of reserved tickets for play). Rows should be ordered by decreasing reserved tickets. In the case of a tie, rows should be sorted by increasing id of play Examples: You are given two tables describing theater plays and reservations for these plays in specific theaters. create table plays id integer not null, title varchar (40) not null, writer varchar ( 40 ) not null, unique (id) create table reservations id integer not null, play_id integer not null, number_of tickets integer not null, theater varchar ( 40) not null, unique (id) Write an SQL query that counts the total number of tickets reserved for each play. The table of results should contain three columns: id (id of play), title (title of play) and reserved_tickets (total number of reserved tickets for play). Rows should be ordered by decreasing reserved tickets. In the case of a tie, rows should be sorted by increasing id of play Examples: You are given two tables describing theater plays and reservations for these plays in specific theaters. create table plays id integer not null, title varchar (40) not null, writer varchar ( 40 ) not null, unique (id) create table reservations id integer not null, play_id integer not null, number_of tickets integer not null, theater varchar ( 40) not null, unique (id) Write an SQL query that counts the total number of tickets reserved for each play. The table of results should contain three columns: id (id of play), title (title of play) and reserved_tickets (total number of reserved tickets for play). Rows should be ordered by decreasing reserved tickets. In the case of a tie, rows should be sorted by increasing id of play Examples: 2. Given: plays: id title writer 34 The opera of the phantom 35 The legend of the cake 36 Stone swords Lero Gastonx Oscar Glad Arthur King reservations : id play_id number_of_tickets | theater 10 36 30 35 | 13 20 Arthur King Theater The Legend Theater The Legend Theater The Legend Theater The Legend Theater The Jupiter Assembly Theater The Jupiter Assembly Theater The Jupiter Assembly Theater 31 36 21 23 19 29 19 6 32 35 33 36 40 34 41 34 42 34 your query should return: id title | reserved_tickets 34 The opera of the phantom 36 Stone swords 35 The legend of the cake 54 53 43 2. Given: plays: id title writer 34 The opera of the phantom 35 The legend of the cake 36 Stone swords Lero Gastonx Oscar Glad Arthur King reservations : id play_id number_of_tickets | theater 10 36 30 35 | 13 20 Arthur King Theater The Legend Theater The Legend Theater The Legend Theater The Legend Theater The Jupiter Assembly Theater The Jupiter Assembly Theater The Jupiter Assembly Theater 31 36 21 23 19 29 19 6 32 35 33 36 40 34 41 34 42 34 your query should return: id title | reserved_tickets 34 The opera of the phantom 36 Stone swords 35 The legend of the cake 54 53 43 2. Given: plays: id title writer 34 The opera of the phantom 35 The legend of the cake 36 Stone swords Lero Gastonx Oscar Glad Arthur King reservations : id play_id number_of_tickets | theater 10 36 30 35 | 13 20 Arthur King Theater The Legend Theater The Legend Theater The Legend Theater The Legend Theater The Jupiter Assembly Theater The Jupiter Assembly Theater The Jupiter Assembly Theater 31 36 21 23 19 29 19 6 32 35 33 36 40 34 41 34 42 34 your query should return: id title | reserved_tickets 34 The opera of the phantom 36 Stone swords 35 The legend of the cake 54 53 43

Members

  • Access to 2 Million+ Textbook solutions
  • Ask any question from 24/7 available
    Tutors
$9.99
VIEW SOLUTION

OR

Non-Members

Get help from Programming Tutors
Ask questions directly from Qualified Online Programming Tutors.
Best for online homework assistance.