Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write SQL queries that answer the following questions. Make sure you compose a query that does not use literal values determined by perusing the tuples.
Write SQL queries that answer the following questions. Make sure you compose a query that does not use literal values determined by perusing the tuples. Also, remember some queries may generate an empty result.
For each shark found in the shark table determine the number of detections for the shark as documented within the database. Each tuple in the result should contain the sharks name, sharks id and the number of detections. In the result, rename the number of detections to sightings
Determine the number of shark detections for each bay as documented in the database Each tuple in the result should contain the bays name and the number of detections. Sort the result by the number of detections in descending order.
What receiver has been documented as having the most number of shark detections? The result should contain the receivers area, town, state, and the number of detections. There is one receiver that has the maximum value.
Make a separate table from the receiver table where the records are for the bayside receivers. Name the new table baysideencounters. Remember, a table can only be created once. If you attempt to create the same table multiple times it will generate an error.
Which sharks have been documented as part of an attack. The result should contain the shark.id shark.name, sex, length and number of detections.
For each bay each name in the bay table create an aggregated field that contains a list of the receivers in that bay represented by the field area The result set should contain the bay name and the grouped area name for the receivers. Do not duplicate area names within the grouped list of receivers.
Which is the largest shark by length Return the sharks name in the result.
How many shark sightings have occurred for the different towns in the database? The result should contain the town name, state and shark detections.
Find all female sharks that are less than feet. Return all fields from the shark table and order the results by length in ascending order..
For each sponsor in the sponsor table, determine the number of receivers they sponsor. The result should contain the sponsor name and the count. Make sure all sponsors appear in the result. If a sponsor does not appear in the receiver table, then the count for the number of receivers should be
Determine the total number of shark detections associated with their sponsored receivers. If a receiver is not sponsored the detections should still be aggregated and assigned to the NULL sponsor. The result should contain the sponsor name and the number of detections.
For each attack, report the shark name, if the attack was fatal, the description of the attack,the date of the attack, the victims activity when attacked the town where the attacked occurred, the state, the victims name, the victims age,
Determine the town that first deployed a receiver. The result should contain the town, the state and the date of deployment for the receiver.
How many receivers are deployed for each town? The result should contain the town name, the town state, and the number of receivers renamed to numreceivers All towns in the township table should appear in the result. If a town has no receivers, then the count numreceivers should be
Find the towns that do not have a receiver and not have an attack. Return the town name and the state of all towns not found in either the receiver table or the attack table.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started