Preview

Assignment2

Satisfactory Essays
Open Document
Open Document
619 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Assignment2
Question 1
In SQL, specify the following queries on the database specified in Figure 1 below using the concept of nested queries and the concepts described in chapter 5.
a. Retrieve the names of all employees who work in the department that has the employee with the highest salary among all employees.
SELECT fname, minit, lname FROM employee WHERE dno =(SELECT dno FROM employee WHERE salary= (SELECT MAX(Salary) FROM employee)); b. Retrieve the names of all employees whose supervisor’s supervisor has '888665555' for SSN.
SELECT fname, minit, lname FROM employee WHERE Super_ssn IN (SELECT ssn FROM employee WHERE Super_ssn= '888665555');
c. Retrieve the names of employees who make at least $10,000 more than the employee who is paid the least in the company.
SELECT fname, minit, lname FROM employee WHERE Salary >= 10000 + (SELECT MIN(Salary) FROM employee');

Question 2
In SQL, specify the following queries on the database specified in Figure 1 above. Show the query results if applied to the database of Figure 2 below.
a. For each department whose average employee salary is more than $30,000, retrieve the department name and the number of employees working for that department.
SELECT Dname, count(dno) FROM employee INNER JOIN department ON employee.dno = department.dnumber GROUP BY Dno HAVING (AVG(Salary) > 30000);
b. For part a above, suppose we want the number of male employees in each department rather than all employees. Hint: consider using a nested query.Figure 2
SELECT Dname, count(dno) FROM employee INNER JOIN department ON employee.dno = department.dnumber WHERE sex = 'M' GROUP BY Dno HAVING (AVG(Salary) > 30000);

Question 3
Create an ER diagram for the following case. Write your assumptions about any missing information:
You are working for a consulting company and want to create a very simple database. This database will be used to track problems clients are having and the consultants who are working on them. Each client can have many

You May Also Find These Documents Helpful

  • Good Essays

    Each query in the script file you will create must be numbered (use --1 comments for numbering) and in order. The SQL for the following exercises should be written using notepad and run in SQL*Plus.…

    • 1559 Words
    • 7 Pages
    Good Essays
  • Satisfactory Essays

    Hiredate DATE No No Job VARCHAR2(15) No No Mgrno number(4) no no yes ( to emp.empno) Salary number(8,2) no no Comm number(8,2) no no Deptno number(2) no no yes ( to…

    • 1169 Words
    • 5 Pages
    Satisfactory Essays
  • Satisfactory Essays

    M1 Unit 4 Assignment

    • 438 Words
    • 2 Pages

    1. Update the employee table, add a salary column (Number type with 7 length) into the employee table. Use a number format with a 2 digit decimal from the right.…

    • 438 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Dbm380 Wk2

    • 772 Words
    • 3 Pages

    There will be seven tables in this database source system customer data, order data, corrections table data, comparison results table, drop ship corrections, end system data, and workflow status. The source system table will be comprised of columns for customer name, customer purchase order number, status, and transmitted date. The customer table will comprise of columns for customer name and customer number. Corrections table will offer columns for customer purchase order number, system reference data, date received and error message. Drop ship table will consist of customer…

    • 772 Words
    • 3 Pages
    Good Essays
  • Good Essays

    a) A firm has three categories of employees: juniors, seniors and supervisors. They earn $12, $18 and $24 per hour respectively. They have an output of 10, 16 and 22 units of product per hour respectively. The 250 employees of the plant have a total…

    • 1317 Words
    • 6 Pages
    Good Essays
  • Good Essays

    1. SELECT e.ename, e.deptno, d.dname, d.deptno FROM dept d LEFT OUTER JOIN emp e ON d.deptno = e.deptno ORDER BY d.deptno; SQL> SELECT e.ename, e.deptno, d.dname, d.deptno 2 FROM dept d 3 LEFT OUTER JOIN emp e 4 ON d.deptno = e.deptno 5 ORDER BY d.deptno; ENAME DEPTNO DNAME DEPTNO ---------- ---------- -------------- ----------…

    • 1542 Words
    • 7 Pages
    Good Essays
  • Good Essays

    Kudler Fine Food Week 4

    • 284 Words
    • 2 Pages

    · Calculate the minimum salary for exempt employees and the maximum salary for non-exempt employees.…

    • 284 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Looking over the Constructit Company they have 1000 employees working for them. The people at Constructit are willing to pay a maximum premium of $4,000 per person. The company has 550 men working for them and 450 women working for them. Out of all the employees 32% of them are involved in a great deal of physical activity during their work day,25% have moderate…

    • 860 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    CTS 2437 Final Exam

    • 630 Words
    • 4 Pages

    5. Create a view that includes the first and last names of full time faculty members, along with…

    • 630 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    FirstName) EmployeeName, concat(EmployeeTitles. Title,' - ',Employees. Level) Title, concat(Employees. Salary ,'(USD)')…

    • 485 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    SELECT clause specifies which columns are to list in the query results. FROM clause specifies which tables are to be used in the query. WHERE clause specifies which rows are to listed in the query result…

    • 314 Words
    • 1 Page
    Satisfactory Essays
  • Powerful Essays

    ( NAME = N'Jeff Thompson Sr - POS 410 - IA - KVO_log', FILENAME = N'D:\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\Jeff Thompson Sr - POS 410 - IA - KVO_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)…

    • 1555 Words
    • 7 Pages
    Powerful Essays
  • Satisfactory Essays

    assignment2

    • 438 Words
    • 2 Pages

    My first victim was my mother I explained to her what memory aid was and how you conducted the class experiment on the students in class. My mother is just like me so she was not very thrilled about the fact that she had to remember information in such short notice. I explained to her that she was not being judged. I started the memory test in a very calm setting which was in my mother's room where she was comfortable. I explained to my mother that I was going to give her a deck of cards. In random format she would need to pick out seven cards. Once she selected the seven cards she had one minute to view the cards in the order that they were selected, and then regurgitate them back to me. Reminder my mother is 52 years old and coincidentally she did very well. Now that I know my mother has very good short-term memory. we have to work on long-term memory, because I always have to remind her of things. I only conducted one memory tests with my mother because she was getting kind of aggravated, and for some odd reason she thought I was making her do my homework. My results with my mother was kind of babbling, because usually my mother act like she cannot hear anything you say. The results were actually the other way around proving that my mother was not telling the truth. Conducting this test on my mother has giving me something to hold over her head in proving that she has selective memory.…

    • 438 Words
    • 2 Pages
    Satisfactory Essays
  • Better Essays

    (1a) Plot histograms for the following variables: Tenure, hourly wage, age and education. Produce separate…

    • 1231 Words
    • 5 Pages
    Better Essays
  • Good Essays

    table based on data in another table. They generally are used when tables have some kind…

    • 1885 Words
    • 8 Pages
    Good Essays