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

  • 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

    Assignment1

    • 584 Words
    • 3 Pages

    The Adelaide Desalination Project (ADP) team accomplished to deliver the project’s scope within the original budget of $1.842 billion and 19 days ahead of the originally approved schedule. The project’s clear objectives added a definite business value to the organization SA Water.…

    • 584 Words
    • 3 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

    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

    Salary from master.dbo. Employees Employees left join master.dbo. Countries Countries on Employees. CountryID = Countries. CountryID left join master.dbo.…

    • 485 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Mis562 Week 2

    • 2131 Words
    • 9 Pages

    SQL> SELECT ENAME, JOB, SAL FROM EMP WHERE EMPNO NOT IN (SELECT MGR FROM EMP WHERE MGR IS NOT NULL) OR SAL > 1000;…

    • 2131 Words
    • 9 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
  • Good Essays

    Week 1 Submission

    • 1120 Words
    • 5 Pages

    5. Select all employees that are in department 10 and 30. Use the IN operator.…

    • 1120 Words
    • 5 Pages
    Good Essays
  • Satisfactory Essays

    CTS 2437 Final Exam

    • 630 Words
    • 4 Pages

    1. Select the number of courses that have more than 20 persons enrolled, the total number of students in courses with more than 20 persons, and the average enrollment per each course with more than 20 persons.…

    • 630 Words
    • 4 Pages
    Satisfactory 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