In this lab, you will learn how to write Advanced queries using Aggregate Functions and Table Joins. You will write 10 SQL SELECT statements to query the STUDENT schema. Your Select Statements should run error-free and should be valid.
Submit two separate files: one plain text file (.txt or .sql file) with your SELECT statements only; and the other document (doc/docx/pdf) include both your SELECT statements and your query results (copy and paste text or screen shots). The instructor and TA should be able to run your plain text source file as script and generate the same output as shown in your result document.
Q1. List all courses that have “Intro to Information Systems” as prerequisite. (HINT: use a subquery)
Q2. List all courses with above average cost. Display course description, cost, and the average cost of all courses. (HINT: use a subquery)
Q3. For each zip that has at least one instructor, list the total number of instructors in that zipcode.
Q4. For each city in the state of CT, list the total number of students live in that city. Display city, state, number of students in descending order.
— AGGREGATION OF FULL RESULT SET
Q5. Find the minimum, maximum, and average grade of final exams in sections taught by Todd Smythe.
Q6: For all students who took “Intro to Information Systems”, calculate the highest, lowest, and average midterm exam grade for each section. Display Section No and calculation results.
— TABLE JOIN WITH HAVING-CLAUSE
Q7. List the instructor id and name of the instructors that teach fewer than 10 sections regardless of student enrollment.
Q8. Show which city has the most students. Display city and state, and number of students.
Q9: List all zipcodes where at least three students AND at least four instructor reside. Show zip, state and city.
Q10: List all cities that have 10 or more students and instructor combined. Show city, state, number of student residents, number of instructor residents, and total student/instructor residents in that city. Sort by total in descending order.
Learning Resources
https://www.w3schools.com/sql/sql_join.asp
https://docs.oracle.com/database/121/SQLRF/functions.htm#SQLRF006
Attachments: