Preview

Hjgbjhhljk

Good Essays
Open Document
Open Document
2358 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Hjgbjhhljk
SQL Exercises (with answers) Give the SQL commands for the following and answer any associated questions: (A) “Simple” SELECT Command Questions 1. Display all information in the tables EMP and DEPT. SELECT * FROM emp; SELECT * FROM dept; 2. 3. 4. 5. 6. 7. Display only the hire date and employee name for each employee. SELECT hiredate, ename FROM emp; Display the hire date, name and department number for all clerks. SELECT hiredate, ename, deptno FROM emp WHERE job = ’CLERK’; Display the names and salaries of all employees with a salary greater than 2000. SELECT ename, sal FROM emp WHERE sal > 2000; Display the names of all employees with an ‘A’ in their name. SELECT ename FROM emp WHERE ename LIKE ’%A%’; Display the names of all employees with exactly 5 letters in their name. SELECT ename FROM emp WHERE ename LIKE ’ ’; Display the names and hire dates of all employees hired in 1981 or 1982 (Note in Visual Basic or Access SQL you need to refer to dates in a WHERE clause between #s, eg. #1 Jan 2000#). SELECT ename, hiredate FROM emp WHERE hiredate LIKE ’%1981’ OR hiredate LIKE ’%1982’; —OR— SELECT ename, hiredate FROM emp WHERE hiredate >= ’1/1/1981’ AND hiredate 0; 1

8.

3.

4. 5.

Display the department number and number of clerks in each department. SELECT deptno, count(job) FROM emp WHERE job = ’CLERK’ GROUP BY deptno; Display the department number and total salary of employees in each department that employs four or more people. SELECT deptno, sum(sal) FROM emp GROUP BY deptno HAVING count(empno) >= 4; Display the employee number of each employee who manages other employees with the number of people he or she manages. SELECT mgr, count(mgr) FROM emp WHERE mgr IS NOT NULL GROUP BY mgr;

6.

(C) Join SELECT Command Questions 1. 2. 3. Display the name of each employee with his department name. SELECT ename, dname FROM emp INNER JOIN dept ON emp.deptno = dept.deptno; Display a list of all departments with the employees in each department. SELECT

You May Also Find These Documents Helpful

  • Good Essays

    The SELECT statement is the primary means of extracting data from database tables, and allows you to determine exactly which data you want to extract by means of different comparison operators used in the WHERE clause. This includes the use of specific "wild card" characters which allow you to search for character or number patterns within the data. You can also perform mathematical expressions within the SELECT statement to create derived output. The ORDER BY clause allows you to sort the output data in either ascending (the default) or descending order. Lab #5 will explore all of these applications of the SELECT statement.…

    • 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

    2. Update the employee table and provide a salary for each employee using the salary column added in the previous problem. Validate the rows are there using a SELECT clause.…

    • 438 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

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

    • 1542 Words
    • 7 Pages
    Good Essays
  • Satisfactory Essays

    Payroll select concat(Employees. FirstName,' ',Employees. LastName) Fullname, Countries. CountryName, Countries.…

    • 485 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Mis562 Week 2

    • 2131 Words
    • 9 Pages

    2. SQL> --2. List employees name, job, and salary that is a manager and has a salary > $1,000…

    • 2131 Words
    • 9 Pages
    Satisfactory Essays
  • Satisfactory Essays

    CS320 Lab1

    • 874 Words
    • 3 Pages

    format and submit it to the course canvas. This covers SQL Part A (Chapters 2,8&…

    • 874 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    Assignment Homework

    • 1073 Words
    • 5 Pages

    2. Write queries that performs a join, a subquery, a correlated subquery using the student, enrollment, grade, and zipcode tables. Execute each query to show that it produces the same results. (15 pts)…

    • 1073 Words
    • 5 Pages
    Powerful Essays
  • Good Essays

    The organization currently employs 130 employees in a departmentalized system. Each department is supervised by a department director who is responsible for the communication and documentation to support internal and external transactions that occur in his or her department. For example, the housekeeping director orders all of the cleaning supplies for the facility and sends the purchase orders he completes for the supplies to the accounting office upon delivery of the goods.…

    • 1014 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Week2 Discussion2 DBMS

    • 480 Words
    • 3 Pages

    Given the business rule “an employee may have many degrees,” discuss its effect on attributes, entities, and relationships. (Hint: Remember what a multivalued attribute is and how it might be implemented.)…

    • 480 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Chapter 1 Level 1

    • 689 Words
    • 3 Pages

    Name the Employee and Customer tables according to their contents and the Leszynski/Reddick naming conventions.…

    • 689 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    After information is gathered about the employee; most of what was mentioned before, and input into the system a query can be designed to pull that information from the tables. In order to pull information from…

    • 782 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    These departments have managers and subordinates who all possess the relevant and significant expertise needed for every specific type of department. As every department has a head or a manager and their supporting subordinates, jobs are broken down into simple, routine and well-defined tasks that are able to be achieved most effectively and efficiently.…

    • 1511 Words
    • 7 Pages
    Powerful Essays
  • Satisfactory Essays

    there are 6 departments I the head office and are headed by 6 manager i.e. Hr manager, Finance manager, Inventory manager, Production manager,…

    • 401 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Departmentation

    • 664 Words
    • 3 Pages

    Departmentation can be defined as the grouping of jobs under the authority of a single manager, according to some rational basis, for the purposes of planning, coordination and control. The number of departments in an organization depends on the number of different jobs, i.e., the size and complexity of the business.…

    • 664 Words
    • 3 Pages
    Satisfactory Essays

Related Topics