Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Subqueries Assignment The city s Crime Analysis unit has submitted the following data requests. Provide the SQL statements using subqueries to satisfy the requests. Test
Subqueries Assignment The citys Crime Analysis unit has submitted the following data requests. Provide the SQL statements using subqueries to satisfy the requests. Test the statements and show execution results. List the name of each officer who has reported more than the average number of crimes officers have reported. SQLMySQL Code: Screenshot: List the names of all criminals who have committed less than average number of crimes and arent listed as violent offenders. SQLMySQL Code: Screenshot: List appeal information for each appeal that has a less than average number of days between the filing and hearing dates. SQLMySQL Code: Screenshot: List the names of probation officers who have had a less than average number of criminals assigned. SQLMySQL Code: Screenshot: List each crime that has had the highest number of appeals recorded. SQLMySQL Code: Screenshot: List the information on crime charges for each charge that has had a fine above average and a sum paid below average. SQLMySQL Code: Screenshot: List the names of all criminals who have had any of the crime code charges involved in crime ID SQLMySQL Code: Screenshot: Use a correlated subquery to determine which criminals have had at least one probation period assigned. SQLMySQL Code: Screenshot: List the names of officers who have booked the highest number of crimes. Note that more than one officer might be listed. SQLMySQL Code: Screenshot: The criminal data warehouse contains a copy of the CRIMINALS table that needs to be updated periodically from the production CRIMINALS table. The data warehouse table is named CRIMINALSDW Use a single SQL statement to update the data warehouse table to reflect any data changes for existing criminals and to add new criminals. Note: Use a MERGE statement to satisfy this request. SQLMySQL Code: Screenshot:
Subqueries Assignment
The citys Crime Analysis unit has submitted the following data requests. Provide the SQL
statements using subqueries to satisfy the requests. Test the statements and show execution
results.
List the name of each officer who has reported more than the average number of crimes
officers have reported.
SQLMySQL Code:
Screenshot:
List the names of all criminals who have committed less than average number of crimes
and arent listed as violent offenders.
SQLMySQL Code:
Screenshot:
List appeal information for each appeal that has a less than average number of days
between the filing and hearing dates.
SQLMySQL Code:
Screenshot:
List the names of probation officers who have had a less than average number of
criminals assigned.
SQLMySQL Code:
Screenshot:
List each crime that has had the highest number of appeals recorded.
SQLMySQL Code:
Screenshot:
List the information on crime charges for each charge that has had a fine above average
and a sum paid below average.
SQLMySQL Code:
Screenshot:
List the names of all criminals who have had any of the crime code charges involved in
crime ID
SQLMySQL Code:
Screenshot:
Use a correlated subquery to determine which criminals have had at least one probation
period assigned.
SQLMySQL Code:
Screenshot:
List the names of officers who have booked the highest number of crimes. Note that more
than one officer might be listed.
SQLMySQL Code:
Screenshot:
The criminal data warehouse contains a copy of the CRIMINALS table that needs to be
updated periodically from the production CRIMINALS table. The data warehouse table is
named CRIMINALSDW Use a single SQL statement to update the data warehouse
table to reflect any data changes for existing criminals and to add new criminals. Note:
Use a MERGE statement to satisfy this request.
SQLMySQL Code:
Screenshot:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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