
Concept explainers
Using the relations in the appendix, write the following queries in
SQL:
i. Display a list of all instructors, showing each instructor’s ID
and the number of sections taught. Your query should use an
outer join, and should not use sub-queries.
ii. Write the same query as in part a, but using a scalar subquery and not using outer join.
iii. Display the list of all course sections offered in spring 2018,
along with the ID and name of each instructor teaching the
section. If a section has more than one instructor, that section
should appear as many times in the result as it has instructors.
If a section does not have any instructor, it should still appear
in the result with the instructor name set to “—”.
iv. Display the list of all departments, with the total number of
instructors in each department, without using sub-queries.
Make sure to show departments that have no instructors, and
list those departments with an instructor count of zero.

Step by stepSolved in 4 steps

- How do I make space on the Header on SQL? please see image.Thank you. SELECT BRAND_NAME, BRAND_TYPE, round(AVERAGE,2) AS 'Average Price', UnitsSoldFROM (LGBRAND INNER JOIN (SELECT BRAND_ID, AVG(PROD_PRICE) AS AVERAGE FROM LGPRODUCT GROUP BY BRAND_ID) AS SUB1 ON LGBRAND.BRAND_ID = SUB1.BRAND_ID) INNER JOIN (SELECT BRAND_ID, SUM(LINE_QTY) AS UNITSSOLD FROM LGPRODUCT INNER JOIN LGLINE ON LGPRODUCT.PROD_SKU = LGLINE.PROD_SKU GROUP BY BRAND_ID) AS SUB2 ON LGBRAND.BRAND_ID = SUB2.BRAND_IDORDER BY BRAND_NAMEarrow_forwardQuestion 6 List classroom ID, building name, class ID and class description. Use a LEFT JOIN to list all the classrooms in the BSU_Classrooms table and show matching Class ID and class description from the BSU_Class table. Sort results in descending order by classroom ID. Paste the SQL code here: Paste the resulting table here:arrow_forwardWrite a query that uses INNER JOIN TO connect the EMPLOYEE, EMPPROJACT, PROJACT and PROJECT tables. Include the Project number , Department number, Project start and end date and AC STAFF WHERE They belong to department D11 , Salary is more than or equal to 65 percent of $15,000 AND Salary is less than or equal to 130 percent of $40,000arrow_forward
- Write a query that returns the EMP_NUM and Number of ratings he/she earned (based on EARNEDRATING table, call this Num_RTG), for those who had at least got 1 rating earned, but the number of ratings he/she earned must lower than the average number of ratings for all employees who had earned ratings before, and such employee has been served as “Copilot” before.arrow_forwardCreate a function to increment the salary of employees of an organization by 15%, and for employees with department ID 100 give another 10% hike on the updated salary. Also, write the query to update the salary of all records of the salary column in the employee table using the created function. In PL/SQLarrow_forwardHow do you qualify the name of a field in an SQL query? When is it necessary to do so? give few examplesarrow_forward
- Do a SQL query using their data format to see who hasn't attended any classes there. Please avoid using set operations and subqueries (use an outer join).arrow_forward8. Using a subquery in the FROM clause, find the average unit price of in-stock trucks of any make/model in SQL.arrow_forwardGiven the table PRODUCT(ProductID, ProductName, ProductClass, ProductWeight, ProductStyle, ProductColor, ProductPrice). Note: ProductWeight and ProductPrice are numeric fields, and the other attributes are character fields, i.e., store text. Write a SQL query to display the product class whose average price is at least 50arrow_forward
- Write the SQL code that will change the PROJ_NUM to 14 for employees who were hired before January 1, 1994, and whose job code is at least 501. When you finish Problems 7–15, the EMP_2 table will contain the data shown in Figure P8.15.arrow_forwardWrite queries in SQL to answer each of the following questions: 1. Find all students in Comp. Sci. dept 2. Find all students with total credits > 100 3. Find all students who took course in Spring 2010 (Remove duplicates please) 4. Find all courses taken by the student whose ID is 76543 and also find his name create table student (ID varchar(5), name varchar(20) not null, dept_name varchar(20), tot_cred numeric(3,0), primary key (ID) ); create table takes (ID varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0), grade varchar(2), primary key (ID, course_id, sec_id, semester, year) ); insert into student values ('00128', 'Zhang', 'Comp. Sci.', '102'); insert into student values ('12345', 'Shankar', 'Comp. Sci.', '32'); insert into student values ('19991', 'Brandt', 'History', '80'); insert into student values ('23121', 'Chavez', 'Finance', '110'); insert into student values ('44553', 'Peltier', 'Physics', '56'); insert into student values…arrow_forwardwhat is the difference between inner and outer join in sql?arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





