Question

EMPLOYEE Field Name EMP_ID EMP_LNAME EMP_MI EMP_FNAME EMP_SEX EMP_AGE EMP_SALARY EMP_HIREDATE DEPT_CODE Table: DEPARTMENT DEPT_CODE BIOL...

EMPLOYEE
Field Name
EMP_ID EMP_LNAME EMP_MI EMP_FNAME EMP_SEX EMP_AGE EMP_SALARY EMP_HIREDATE DEPT_CODE
Table: DEPARTMENT
DEPT_CODE
BIOL CPTR HIST MATH RELB
Data Type
Text
Text
Text
Text
Text Number Currency Date/Time Text
DEPT_TITLE
Biology
Computer Science History Mathematics Religion
  
Field Name
DEPT_CODE DEPT_TITLE
Data Type
Text Text
INSTRUCTIONS
Use SQL commands to create the tables and enter the data shown above using MS Access. Write the following SQL statement given below:
1.
2.
3.
4.
5.
6. 7.
8. 9. 10. 11. 12.
Write the SQL statement to create a new table called TEMP whose attributes should be similar to that of table EMPLOYEES. Save as Query1-TABLE TEMP
Write the SQL statement to Alter table TEMP and add the primary key. Save as Query2-ALTER & ADD PRIMARY KEY
Write the SQL statement to insert into TEMP, the values contained in the first row of the EMPLOYEES table. Save as Query3-INSERT INTO TEMP
Write the SQL statement to DELETE records from TEMP where EMP_HIREDATE is before 2010. Save as Query4-DELETE FROM TEMP
Write the SQL statement to INSERT all the rows of EMPLOYEES table into TEMP. Save as Query5- INSERT INTO & SELECT SUBQUERY
Write the SQL statement to delete table TEMP from the database. Save as Query6-DROP TEMP. Write the SQL statement to display all the rows for employees whose hired date was after January 1, 2018. Save as Query7-DATE & COMPARISON
Write the SQL statement to display all rows for employees who do not have a middle initial using the IS NULL special operator. Save as Query8-MIDDLE INITIAL IS NULL.
Write the SQL statement to display all rows for employees whose last name begins with ‘B’ using the LIKE special operator. Save as Query9 –EMPLOYEES WITH LASTNAME BEGIN WITH B.
Write the SQL statement to display all rows for employees whose last name is Adams. Save as Query-EMPLOYEES LASTNAME IS ADAMS.
Write the SQL statement to display all rows for employees in the Computer Science Department using the IN special operator. Save as Query11-EMPLOYEES IN MATH & COMPUTER SCIENCE. Write the SQL statement to display last name, first name and age of all employees in descending order. Save as Query12-ORDER BY LASTNAME.

13. Write the SQL statement to count the total number of employees using the alias TOTAL_EMPLOYEE. Save as Query13-TOTAL_EMPLOYEE.
14. Write the SQL statement to find the average age of all employees. Use the Alias AVERAGE_AGE. Save as Query14-AVERAGE AGE.
15. Write the SQL statement to display first name, last name and salary of the employee with the highest salary. Save as Query15-HIGHEST PAY.
16. Write the SQL statement to display first name, last name and sex of the employee grouped by sex. Save as Query16-GROUP BY SEX.
17. Write the SQL statement to display first name, last name and sex of all female employees Grouped by sex. Save as Query17-GROUP BY SEX FEMALES. Hint: include a HAVING CLAUSE.
18. Write the SQL statement to display first name, last name and department of all employees. Save as Query18- JOIN QUERY.
19. Write the SQL statement to display all rows for all employees that are older than 30 and are female. Save as Query19-USING AND.
20. Write the SQL statement to display all rows for all employees that are either from the Computer Science department. Save as Query20-USING OR
21. Using the three (3) Data Model types, show the tables above in their three different phases.

Homework Answers

Answer #1

1.CREATE TABLE TEMP (
EMP_ID text,
EMP_LNAME text,
EMP_MI text,
EMP_FNAME text,
EMP_SEX text,
EMP_AGE number,
EMP_SALARY currency,
EMP_HIREDATE datetime,
DEPT_CODE text);
Save as :Query1-TABLE TEMP

2. ALTER TABLE TEMP
ADD PRIMARY KEY (EMP_ID);
Save as :Query2-ALTER & ADD PRIMARY KEY

3. INSERT INTO TEMP
SELECT TOP 3 * FROM EMPLOYEE;
Save as Query3-INSERT INTO TEMP

4. DELETE * FROM TEMP WHERE YEAR(EMP_HIREDATE)<2010;
Save as Query4-DELETE FROM TEMP

5. INSERT INTO TEMP
SELECT TOP * FROM EMPLOYEE;
Save as Query5- INSERT INTO & SELECT SUBQUERY

6. DROP TABLE TEMP;
Save as Query6-DROP TEMP

7. SELECT * FROM EMPLOYEE WHERE EMP_HIREDATE>'2018-1-1';
Save as Query7-DATE & COMPARISON

8. SELECT * FROM EMPLOYEE WHERE EMP_MI IS NULL;
Save as Query8-MIDDLE INITIAL IS NULL

9. SELECT * FROM EMPLOYEE WHERE EMP_LNAME LIKE 'B%';
Save as Query9 –EMPLOYEES WITH LASTNAME BEGIN WITH B

10. SELECT * FROM EMPLOYEE WHERE EMP_LNAME=ADAMS';
Save as Query-EMPLOYEES LASTNAME IS ADAMS

11. SELECT * FROM EMPLOYEE WHERE DEPT_CODE IN('CPTR','MATH');
Save as Query11-EMPLOYEES IN MATH & COMPUTER SCIENCE

12. SELECT EMP_LNAME,EMP_FNAME,EMP_AGE FROM EMPLOYEE ORDER BY DESC;
Save as Query12-ORDER BY LASTNAME.

13. SELECT COUNT(EMP_ID) AS TOTAL_EMPLOYEE FROM EMPLOYEE;
Save as Query13-TOTAL_EMPLOYEE

14. SELECT AVG(EMP_AGE) AS AVERAGE_AGE FROM EMPLOYEE;
Save as Query14-AVERAGE AGE

15. SELECT EMP_FNAME,EMP_LNAME,EMP_SALARY FROM EMPLOYEE WHERE EMP_SALARY=(select max(EMP_SALARY) from EMPLOYEE);
Save as Query15-HIGHEST PAY

16. SELECT EMP_FNAME,EMP_LNAME,EMP_SEX FROM EMPLOYEE GROUP BY EMP_SEX;
Save as Query16-GROUP BY SEX

17. SELECT EMP_FNAME,EMP_LNAME,EMP_SEX FROM EMPLOYEE GROUP BY EMP_SEX HAVING EMP_SEX='female';
ave as Query17-GROUP BY SEX FEMALES. Hint: include a HAVING CLAUSE

18. SELECT EMPLOYEE.EMP_FNAME, EMPLOYEE.EMP_LName,DEPARTMENT.DEPT_TITLE FROM EMPLOYEE
INNER JOIN DEPARTMENT ON EMPLOYEE.DEPT_CODE=DEPARTMENT.DEPT_CODE;
Save as Query18- JOIN QUERY

19. SELECT * FROM EMPLOYEE WHERE EMP_AGE>30 AND EMP_SEX='female';
Save as Query19-USING AND

20. SELECT * FROM EMPLOYEE WHERE DEPT_CODE IN('BIOL','HIST','MATH','RELB') OR DEPT_CODE='CPTR';
Save as Query20-USING OR

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a SQL statement which joins the parts table with the supplier table and lists the...
Write a SQL statement which joins the parts table with the supplier table and lists the part_name, supplier_name for all parts in the part table. The supplier_id column in the suppliers table is the primary key in the suppliers table, and this key has been exported to the parts table where it is a foreign key. You should use an inner join for this query. Write a SQL statement which joins the parts table with the suppliers table and lists...
Lab 5 Queries with Multiple Tables In this lab, we do queries more than one table....
Lab 5 Queries with Multiple Tables In this lab, we do queries more than one table. SQL provides two different techniques for querying data from multiple tables: • The SQL subquery • The SQL join As you will learn, although both work with multiple tables, they are used for slightly different purposes. We used WMCRM database which is what we created in Lab 4. Here is the summary of the database schema (where schema is used in its meaning of...
1.Write a SELECT statement that returns "Representative full name" from sales_rep table. Format "Representative full name"...
1.Write a SELECT statement that returns "Representative full name" from sales_rep table. Format "Representative full name" column with the rep_first_name column , a comma, a space and the rep_last name. Return only the sales representatives whose last name starts with "Mar" 2. Write a SELECT statement that  joins the sales_rep table to the sales_totals table using JOIN clause and returns these columns : "Representative Last name" : rep_last_name from sales_rep table " Year of sales " : sales_year column of sales_totals...
-- Table construction (just 1 simplest possible way) CREATE TABLE PetType ( petTypeId VARCHAR(10) PRIMARY KEY,...
-- Table construction (just 1 simplest possible way) CREATE TABLE PetType ( petTypeId VARCHAR(10) PRIMARY KEY, animalType VARCHAR(20), breed VARCHAR(20) ); CREATE TABLE Owner ( ownerId VARCHAR(10) PRIMARY KEY, firstName VARCHAR(20), lastName VARCHAR(20) NOT NULL, homePhoneNumber VARCHAR(20), streetAddress VARCHAR(80), suburb VARCHAR(20), postcode VARCHAR(10) ); CREATE TABLE Pet ( petId VARCHAR(10) PRIMARY KEY, petName VARCHAR(20), sex CHAR(1) CHECK (sex IN ('M', 'F')), petTypeId VARCHAR(10) FOREIGN KEY REFERENCES PetType ); CREATE TABLE PetAndOwner ( ownerId VARCHAR(10), petId VARCHAR(10), PRIMARY KEY (ownerId, petId),...
Use the following tables to answer Q5 and Q6. Tourist (tno, Name, phone, age,loc) Vehicle (Vno,...
Use the following tables to answer Q5 and Q6. Tourist (tno, Name, phone, age,loc) Vehicle (Vno, model, mileage, owner_name, owner_ph)) Rented (tno, Vno) 5. (i)Write an SQL query, to create the table vehicle with following constraints: Vno should begin with second letter ‘v’; Models are one among Thar, X3. Mileage should be above 18 and below 25. No two records can have same phone (ii) Write an SQL query to retrieve the name of the owner who does owns X3...
Specify the following queries in SQL on the COMPANY database. Show the result of each query....
Specify the following queries in SQL on the COMPANY database. Show the result of each query. Retrieve the names of all employees in department 5 who work more than 10 hours per week on the ‘ProductX’ project. List the names of all employees who have a dependent with the same first name as themselves. Find the names of all employees who are directly supervised by ‘Franklin Wong’. Specify the following updates using the SQL update commands. Show the state of...
Using the Company database in Oracle, construct SQL queries for the following (note: I will make...
Using the Company database in Oracle, construct SQL queries for the following (note: I will make the files to create and populate the Company database available on Isadore shortly): List the last name and address of managers who have a dependent with the same first name as themselves. Retrieve the names of all employees who are directly supervised by ‘Franklin Wong’. Retrieve the names of employees in the Research department who work more than 20 hours per week on the...
1. For the Pet Database described in the previous practical, write an SQL statement with a...
1. For the Pet Database described in the previous practical, write an SQL statement with a subquery to list all the people in the Owner table who own more than one pet. should be a collum of the total number of pets owned, owner id, first name and last name -- DROP TABLE PetAndOwner, Pet, PetType, Owner; CREATE TABLE PetType ( petTypeId VARCHAR(10) PRIMARY KEY, animalType VARCHAR(20), breed VARCHAR(20) ); CREATE TABLE Owner ( ownerId VARCHAR(10) PRIMARY KEY, firstName VARCHAR(20),...
Save your select statements as a script. Place the semicolon at the end of each SQL...
Save your select statements as a script. Place the semicolon at the end of each SQL statement. Please number your select statements from 1 to 8 in your script and comment out each number. Include your name and student number as a comment at the top of your script. The name of the script has to be Assignment1_JohnSmith. Instead of JohnSmith use your First Name and Last Name. Upload your script trough Blackboard. Use SQL Developer to create the My...
Using MySQL... Join the Students, Enrollment, and Classes table to display the UniqueCode and the students’...
Using MySQL... Join the Students, Enrollment, and Classes table to display the UniqueCode and the students’ classes (34 rows) Alter the Enrollment table to create column FullName Update the Enrollment table (using a subquery) to fill in the FullName selecting the students from the Student table (34 rows changed) Using Union (WHERE conditions limited to 1 condition each), display the students names whose HeightInches is greater than 65 or less than 72 (13 rows) Using “Intersection”, display the students names...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT