Hi! I need help answering these 3 questions on SQLQuery. Please help! The database is below.
1. Count the number of courses taught by all adjunct and full time faculty members during the semester and their total enrollments for all classes they teach.
2. List first and last names only of all adjunct faculty members who are teaching more than 1 course , the total enrollment for those courses, and the number of courses the faculty members teach.
3. Display the last names of all full-time faculty members whether or not they are teaching a course. Display the number of courses each faculty member is teaching. Also display the overall total number of courses taught by full-time faculty members and the total revenue from those courses.
Using this database (faculty.sql)
GO
IF DB_ID('Faculty') IS NOT NULL
DROP DATABASE Faculty
GO
CREATE DATABASE Faculty
GO
CREATE TABLE Faculty
(Faculty_ID VARCHAR(2),
LastName VARCHAR(20),
FirstName VARCHAR(20),
Department VARCHAR(10),
Campus VARCHAR(10));
INSERT INTO Faculty VALUES ('1', 'Brown', 'Joe', 'Business',
'Kent');
INSERT INTO Faculty VALUES ('2', 'Smith', 'John', 'Economics',
'Kent');
INSERT INTO Faculty VALUES ('3', 'Jones', 'Sally', 'English',
'South');
INSERT INTO Faculty VALUES ('4', 'Black', 'Bill', 'Economics',
'Deerwood');
INSERT INTO Faculty VALUES ('5', 'Green', 'Gene', 'Business',
'South');
CREATE TABLE Course
(Course_ID CHAR(2),
Ref_Number CHAR(5),
Faculty_ID VARCHAR(2),
Term Char(1),
Enrollment INTEGER,
TotRev FLOAT );
INSERT INTO Course VALUES ('1', '12345', 'a', 'A', 24, 12345.00
);
INSERT INTO Course VALUES ('2', '54321', '3', 'B', 18, 21435.00
);
INSERT INTO Course VALUES ('3', '13524', '1', 'B', 7, 1256.00
);
INSERT INTO Course VALUES ('4', '24653', '1', 'C', 29, 54421.00
);
INSERT INTO Course VALUES ('5', '98765', '5', 'A', 35,
246753.00);
INSERT INTO Course VALUES ('6', '14862', '2', 'B', 14,
9876.00);
INSERT INTO Course VALUES ('7', '96032', '1', 'C', 8,
863159.00);
INSERT INTO Course VALUES ('8', '81256', '5', 'A', 5,
98762.00);
INSERT INTO Course VALUES ('9', '64321', '2', 'C', 23,
2965.00);
INSERT INTO Course VALUES ('10','90908', 'a', 'A', 45,
91724.00);
INSERT INTO Course VALUES ('11','90908', '3', 'A', 23,
73725.00);
INSERT INTO Course VALUES ('12','90908', '3', 'A', 16,
84224.00);
INSERT INTO Course VALUES ('13','90908', 'b', 'A', 13,
42719.00);
CREATE TABLE Adjuncts
(Faculty_ID Char(2),
LastName VARCHAR(20),
FirstName VARCHAR(20),
Department VARCHAR(10),
Campus VARCHAR(10));
INSERT INTO Adjuncts VALUES ('a', 'Minshew', 'Gardner',
'Business', 'Kent');
INSERT INTO Adjuncts VALUES ('b', 'Conley', 'Chris', 'Economics',
'North');
INSERT INTO Adjuncts VALUES ('c', 'Lambo', 'Josh', 'English',
'Cecil');
INSERT INTO Adjuncts VALUES ('d', 'Marone', 'Doug', 'Music',
'Deerwood');
INSERT INTO Adjuncts VALUES ('e', 'Khan', 'Shad', 'Economics',
'South');
INSERT INTO Adjuncts VALUES ('f', 'Jack', 'Miles', 'Business',
'Kent');
Hi,
Here are your solutions
--First Question
select count(Course_ID) as No_of_Courses,c.Faculty_ID,Term,sum(Enrollment) as Total_Enrollment,FirstName,LastName, Department,Campus from course as c
join faculty as f
on f.Faculty_ID=c.Faculty_ID
group by c.Faculty_ID
union
select count(Course_ID) as No_of_Courses,c.Faculty_ID,Term,sum(Enrollment) as Total_Enrollment,FirstName,LastName, Department,Campus from course as c
join adjuncts as a
on a.Faculty_ID=c.Faculty_ID
group by c.Faculty_ID;
--Second Question
select FirstName,LastName,sum(Enrollment) as Total_Enrollment,count(Course_ID) as No_Of_Courses from course as c
join adjuncts as a
on a.Faculty_ID=c.Faculty_ID
group by c.Faculty_ID
having count(Course_ID) >1;
--Third Question
select LastName,count(Course_ID) as No_of_Courses,IFNULL(sum(TotRev), 0) as Total_Revenue from course as c
right join faculty as f
on f.Faculty_ID=c.Faculty_ID
group by c.Faculty_ID
Hope This Helps....... !!!
Hi! I need help answering these 3 questions on SQLQuery. Please help! The database is below....
Please build an Entity Relationship Diagram using the following information: Build a database for a regional university in Western New York called Ithica South University. The university database administrator needs to keep track of the students that attend the university, the courses offered by the university, and the university employees. Ithica tracks the first and last name of each student, as well as their target degree. The university keeps track separately of two subclasses of students, as students are either...
In this hands-on project, you will create an application that allows the user to connect to a database and query the database. Write a Java query application that allows the user to connect to the books database and query the books database. Provide the following predefined queries: Select all authors from the Authors table Select a specific author and list all books for that author. Include each book’s title, year and ISBN. Display the appropriate data for each query. Given...
I need help with the following SQL query for a company database (script given below). The name of the Department. The number of employees working in that department. The number of different projects controlled by this department. The name of the project controlled by this department that has the maximum number of employees of the company working on it. The number of the above project. The cumulative sum of the number of employees of the company working on the projects...
--Create procedure for GetPartNums in SQL --GetPartNums- retrieve all part nums from the database --Database if db_id('TestPremierProducts') is not null begin use master alter database TestPremierProducts set SINGLE_USER with rollback immediate drop database TestPremierProducts end create database TestPremierProducts go USE TestPremierProducts; go /* create the tables */ CREATE TABLE Rep (RepNum int Identity(1,1), LastName VARCHAR(15), FirstName VARCHAR(15), Street VARCHAR(15), City VARCHAR(15), State VARCHAR(2), Zip VARCHAR(5), Commission MONEY, Rate DECIMAL(3,2), PRIMARY KEY (RepNum)); go CREATE TABLE Customer (CustomerNum int Identity(1,1) PRIMARY...
/* I am executing following SQL statement for the below code but I am getting error. Pls, upload screenshot after running it. SQL Statement: SELECT OfferNo, CourseNo FROM Offering WHERE OfferTerm = 'Sum' AND OfferYear = 2012 AND FacSSN IS NULL; */ CREATE TABLE STUDENT( StdSSN INT NOT NULL PRIMARY KEY, StdFName VARCHAR2(50), StdLName VARCHAR2(50), StdCity VARCHAR2(50), StdState VARCHAR2(2), StdZip VARCHAR2(10), StdMajor VARCHAR2(15), StdYear VARCHAR2(20) ); CREATE TABLE FACULTY( FacSSN INTEGER NOT NULL PRIMARY KEY, FacFName VARCHAR(50), FacLName VARCHAR(50), FacCity...
Here is the P4 university database ---Drop tables --Drop Table FACULTY Cascade Constraints; --Drop Table OFFERING Cascade Constraints; --Drop Table STUDENT Cascade Constraints; --Drop Table COURSE Cascade Constraints; --Drop Table ENROLLMENT Cascade Constraints; Create Table STUDENT( Std_ID NUMBER(3) Constraint Student_STD_ID_FK PRIMARY KEY, Std_FN Varchar2 (9), Std_LN Varchar2 (8) , Std_City Varchar2 (10), Std_State Varchar2 (4), Std_Zip Number (5), Std_Major Varchar2 (6), Std_Class Varchar2 (3), Std_GPA NUMBER (3,2)); ---Insert records into Student Insert Into STUDENT Values( 101, 'Joe', 'Smith','Eau Clare','WI',18121,'IS','FR',3.8); Insert...
Help In Database: Next comes the data entry: Make up data for your database, or find real data. You can enter the data with INSERT statements, but it is much easier to use PhpAdmin. It has a form where you can type the data directly. Alternatively, you can use PhpAdmin to import CSV data (comma-separated values), which you can export from Excel. Include at least 3 rows in each of the entity relations, and as many rows as you need...
Using the Premier Products database answer the following questions 1. Using a union, display all customers that have rep number 65 or live in the town of Sheldon. Display all customer information. Insert your snip of the query and resultset together here: 2. Using a subquery, list the rep information for all customers who have the same credit limit as customer number 725. To receive credit for this question, do not explicitly query for rep number 35. Let MySQL do...
SQL I have a database CREATE TABLE vendor ( vid CHAR(2) NOT NULL, vname VARCHAR(25) NOT NULL, PRIMARY KEY (vid) ); CREATE TABLE category ( catid CHAR(2) NOT NULL, catname VARCHAR(25) NOT NULL, PRIMARY KEY (catid) ); CREATE TABLE product ( pid CHAR(3) NOT NULL, pname VARCHAR(25) NOT NULL, price NUMERIC (7,2) NOT NULL, vid CHAR(2) NOT NULL, categoryid CHAR(2) NOT NULL, PRIMARY KEY (pid)); CREATE TABLE region ( rid CHAR NOT NULL, rname VARCHAR(25) NOT NULL, PRIMARY KEY (rid)...
a database of employees that corresponds to the employee-payroll hierarchy is provided (see employees.sql to create the employees for a MySQL database). Write an application that allows the user to: Add employees to the employee table. Add payroll information to the appropriate table for each new employee. For example, for a salaried employee add the payroll information to the salariedEmployees table 1 is the entity-relationship diagram for the employees database Figure 1: Table relationships in the employees database [1]. Add...