Question: Hello, i need help with SQL Since i am not able to use it myself, i would kindly appreciate if you answer the questions SQL
Hello, i need help with SQL
Since i am not able to use it myself, i would kindly appreciate if you answer the questions
SQL queries and also the result of the query in a table form have to be provided.

/* Database Systems, 8th Ed., Rob/Coronel */ /* Type of SQL : SQL Server */ -- execute these two lines one by one */ CREATE DATABASE constructCo; use constructCo; CREATE TABLE PROJECT ( PROJ_NUM varchar(3), PROJ_NAME varchar(25), PROJ_VALUE float(8), PROJ_BALANCE float(8) ); INSERT INTO PROJECT VALUES('15','Evergreen','1453500','1002350'); INSERT INTO PROJECT VALUES('18','Amber Wave','3500500','2110346'); INSERT INTO PROJECT VALUES('22','Rolling Tide','805000','500345.2'); INSERT INTO PROJECT VALUES('25','Starflight','2650500','2309880'); /* -- */ CREATE TABLE EMPLOYEE ( EMP_NUM varchar(3), EMP_LNAME varchar(15), EMP_FNAME varchar(15), EMP_INITIAL varchar(1), EMP_HIREDATE date, JOB_CODE varchar(3) ); INSERT INTO EMPLOYEE VALUES('101','News','John','G','11/8/2000','502'); INSERT INTO EMPLOYEE VALUES('102','Senior','David','H','7/12/1989','501'); INSERT INTO EMPLOYEE VALUES('103','Arbough','June','E','12/1/1996','503'); INSERT INTO EMPLOYEE VALUES('104','Ramoras','Anne','K','11/15/1987','501'); INSERT INTO EMPLOYEE VALUES('105','Johnson','Alice','K','2/1/1993','502'); INSERT INTO EMPLOYEE VALUES('106','Smithfield','William','','6/22/2004','500'); INSERT INTO EMPLOYEE VALUES('107','Alonzo','Maria','D','10/10/1993','500'); INSERT INTO EMPLOYEE VALUES('108','Washington','Ralph','B','8/22/1991','501'); INSERT INTO EMPLOYEE VALUES('109','Smith','Larry','W','7/18/1997','501'); INSERT INTO EMPLOYEE VALUES('110','Olenko','Gerald','A','12/11/1995','505'); INSERT INTO EMPLOYEE VALUES('111','Wabash','Geoff','B','4/4/1991','506'); INSERT INTO EMPLOYEE VALUES('112','Smithson','Darlene','M','10/23/1994','507'); INSERT INTO EMPLOYEE VALUES('113','Joenbrood','Delbert','K','11/15/1996','508'); INSERT INTO EMPLOYEE VALUES('114','Jones','Annelise','','8/20/1993','508'); INSERT INTO EMPLOYEE VALUES('115','Bawangi','Travis','B','1/25/1992','501'); INSERT INTO EMPLOYEE VALUES('116','Pratt','Gerald','L','3/5/1997','510'); INSERT INTO EMPLOYEE VALUES('117','Williamson','Angie','H','6/19/1996','509'); INSERT INTO EMPLOYEE VALUES('118','Frommer','James','J','1/4/2005','510'); /* -- */ CREATE TABLE ASSIGNMENT ( ASSIGN_NUM int, ASSIGN_DATE date, PROJ_NUM varchar(3), EMP_NUM varchar(3), ASSIGN_CHG_HR float(8), ASSIGN_HOURS float(8) ); INSERT INTO ASSIGNMENT VALUES('1001','3/22/2012','18','103','84.5','3.5'); INSERT INTO ASSIGNMENT VALUES('1002','3/22/2012','22','117','34.55','4.2'); INSERT INTO ASSIGNMENT VALUES('1003','3/22/2012','18','117','34.55','2'); INSERT INTO ASSIGNMENT VALUES('1004','3/22/2012','18','103','84.5','5.9'); INSERT INTO ASSIGNMENT VALUES('1005','3/22/2012','25','108','96.75','2.2'); INSERT INTO ASSIGNMENT VALUES('1006','3/22/2012','22','104','96.75','4.2'); INSERT INTO ASSIGNMENT VALUES('1007','3/22/2012','25','113','50.75','3.8'); INSERT INTO ASSIGNMENT VALUES('1008','3/22/2012','18','103','84.5','0.9'); INSERT INTO ASSIGNMENT VALUES('1009','3/23/2012','15','115','96.75','5.6'); INSERT INTO ASSIGNMENT VALUES('1010','3/23/2012','15','117','34.55','2.4'); INSERT INTO ASSIGNMENT VALUES('1011','3/23/2012','25','105','105','4.3'); INSERT INTO ASSIGNMENT VALUES('1012','3/23/2012','18','108','96.75','3.4'); INSERT INTO ASSIGNMENT VALUES('1013','3/23/2012','25','115','96.75','2'); INSERT INTO ASSIGNMENT VALUES('1014','3/23/2012','22','104','96.75','2.8'); INSERT INTO ASSIGNMENT VALUES('1015','3/23/2012','15','103','84.5','6.1'); INSERT INTO ASSIGNMENT VALUES('1016','3/23/2012','22','105','105','4.7'); INSERT INTO ASSIGNMENT VALUES('1017','3/23/2012','18','117','34.55','3.8'); INSERT INTO ASSIGNMENT VALUES('1018','3/23/2012','25','117','34.55','2.2'); INSERT INTO ASSIGNMENT VALUES('1019','3/24/2012','25','104','110.5','4.9'); INSERT INTO ASSIGNMENT VALUES('1020','3/24/2012','15','101','125','3.1'); INSERT INTO ASSIGNMENT VALUES('1021','3/24/2012','22','108','110.5','2.7'); INSERT INTO ASSIGNMENT VALUES('1022','3/24/2012','22','115','110.5','4.9'); INSERT INTO ASSIGNMENT VALUES('1023','3/24/2012','22','105','125','3.5'); INSERT INTO ASSIGNMENT VALUES('1024','3/24/2012','15','103','84.5','3.3'); INSERT INTO ASSIGNMENT VALUES('1025','3/24/2012','18','117','34.55','4.2'); /* -- */ CREATE TABLE EMP_CA ( EMP_NUM varchar(3), EMP_LNAME varchar(15), EMP_FNAME varchar(15), EMP_INITIAL varchar(1), EMP_HIREDATE date, JOB_CODE varchar(3) ); INSERT INTO EMP_CA VALUES('101','News','John','G','11/8/2000','502'); INSERT INTO EMP_CA VALUES('102','Senior','David','H','7/12/1989','501'); INSERT INTO EMP_CA VALUES('103','Arbough','June','E','12/1/1996','500'); INSERT INTO EMP_CA VALUES('104','Ramoras','Anne','K','11/15/1987','501'); INSERT INTO EMP_CA VALUES('106','Smithfield','William','','6/22/2004','500'); INSERT INTO EMP_CA VALUES('107','Alonzo','Maria','D','10/10/1993','500'); INSERT INTO EMP_CA VALUES('108','Washington','Ralph','B','8/22/1991','501'); /* -- */ CREATE TABLE EMP_US ( EMP_NUM varchar(3), EMP_LNAME varchar(15), EMP_FNAME varchar(15), EMP_INITIAL varchar(1), EMP_HIREDATE date, JOB_CODE varchar(3) ); INSERT INTO EMP_US VALUES('101','News','John','G','11/8/2000','502'); INSERT INTO EMP_US VALUES('103','Arbough','June','E','12/1/1996','500'); INSERT INTO EMP_US VALUES('105','Johnson','Alice','K','2/1/1993','502'); INSERT INTO EMP_US VALUES('107','Alonzo','Maria','D','10/10/1993','500'); INSERT INTO EMP_US VALUES('109','Smith','Larry','W','7/18/1997','501'); /* -- */ CREATE TABLE JOB ( JOB_CODE varchar(3), JOB_DESCRIPTION varchar(25), JOB_CHG_HOUR float(8) ); INSERT INTO JOB VALUES('500','Programmer','35.75'); INSERT INTO JOB VALUES('501','Systems Analyst','96.75'); INSERT INTO JOB VALUES('502','Database Designer','125'); INSERT INTO JOB VALUES('503','Electrical Engineer','84.5'); INSERT INTO JOB VALUES('504','Mechanical Engineer','67.9'); INSERT INTO JOB VALUES('505','Civil Engineer','55.78'); INSERT INTO JOB VALUES('506','Clerical Support','26.87'); INSERT INTO JOB VALUES('507','DSS Analyst','45.95'); INSERT INTO JOB VALUES('508','Applications Designer','48.1'); INSERT INTO JOB VALUES('509','Bio Technician','34.55'); INSERT INTO JOB VALUES('510','General Support','18.36'); Write the sql queries to answer each of the following questions in word document. Your answer should consist of the following: - SQL query and also - the result of the query in a table form. 1. Display the number of Jobs from the JOB table. 2. Display the number of different job codes that the employees hold. 3. Display the job code and the number of employees holding each job code. 4. Display for each project (PRO__NUM), the number of employees assigned to work on each project. 5. What is the number of employees assigned to work on project 18. 6. Display for each employee, the number of (distinct) projects the employee is assigned to work on. 7. Show employee 103 and the number of assigned projects on or after 2012-03-23. 8. Use table ASSIGNMENT and display for each employee the total charges over all the assigned projects. - For each assignment line, charges per assignment line is calculated as ASSIGN_CHG_HR *ASSIGN_HOURS. - For each employee, sum up the charges over all the assigned projects. - Use format() function to display 2 decimal points. FORMAT(value, ' N ', 'en-us') 9. Display the employees (EMP_NUM and total charges) whose total charges over all their assigned projects is larger than 1000 . 10. Write a query to get the highest project balance. 11. Who is the oldest employee in the company? You should include - Under each question, you should have: - The SQL query - The result set in a table form
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
