SQL code for: (1) Hint: A NULL in the hours column should be considered as zero hours. Find the ssn, lname, and the total number of hours worked on projects for every employee whose total is less than 40 hours. Sort the result by lname */ /*

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

SQL code for:

(1) Hint: A NULL in the hours column should be considered as zero hours. Find the ssn, lname, and the total number of hours worked on projects for every employee whose total is less than 40 hours. Sort the result by lname */ /*

(2) For every project that has more than 2 employees working on it: Find the project number, project name, number of employees working on it, and the total number of hours worked by all employees on that project. Sort the results by project number. /*

(3) For every employee who has the highest salary in their department: Find the dno, ssn, lname, and salary. Sort the results by department number. */ /*

(4) For every employee who does not work on any project that is located in Houston: Find the ssn and lname. Sort the results by lname /*

(5) Hint: This is a DIVISION query For every employee who works on every project that is located in Stafford: Find the ssn and lname. Sort the results by lname */

### Employee Information

**EMPLOYEE Table:**

| First Name | Middle Initial | Last Name | SSN       | Birthdate  | Address                      | Sex | Salary | Supervisor SSN | Dept No |
|------------|----------------|-----------|-----------|------------|------------------------------|-----|--------|----------------|---------|
| John       | B              | Smith     | 123456789 | 1965-01-09 | 731 Fondren, Houston, TX     | M   | 30000  | 333445555      | 5       |
| Franklin   | T              | Wong      | 333445555 | 1955-12-08 | 638 Voss, Houston, TX        | M   | 40000  | 888665555      | 5       |
| Alicia     | J              | Zelaya    | 999887777 | 1968-01-19 | 3321 Castle, Spring, TX      | F   | 25000  | 987654321      | 4       |
| Jennifer   | S              | Wallace   | 987654321 | 1941-06-20 | 291 Berry, Bellaire, TX      | F   | 43000  | 888665555      | 4       |
| Ramesh     | K              | Narayan   | 666884444 | 1962-09-15 | 975 Fire Oak, Humble, TX     | M   | 38000  | 333445555      | 5       |
| Joyce      | A              | English   | 453453453 | 1972-07-31 | 5631 Rice, Houston, TX       | F   | 25000  | 333445555      | 5       |
| Ahmad      | V              | Jabbar    | 987987987 | 1969-03-29 | 980 Dallas, Houston, TX      | M   | 25000  | 987654321      | 4       |
| James      | E              | Borg      | 888665555 | 1937-11-10 | 450 Stone, Houston, TX       | M   | 55000  | NULL           | 1       |

### Department Information

**DEPARTMENT Table:**

| Department Name | Department Number | Manager SSN | Manager Start Date |
|----------------
Transcribed Image Text:### Employee Information **EMPLOYEE Table:** | First Name | Middle Initial | Last Name | SSN | Birthdate | Address | Sex | Salary | Supervisor SSN | Dept No | |------------|----------------|-----------|-----------|------------|------------------------------|-----|--------|----------------|---------| | John | B | Smith | 123456789 | 1965-01-09 | 731 Fondren, Houston, TX | M | 30000 | 333445555 | 5 | | Franklin | T | Wong | 333445555 | 1955-12-08 | 638 Voss, Houston, TX | M | 40000 | 888665555 | 5 | | Alicia | J | Zelaya | 999887777 | 1968-01-19 | 3321 Castle, Spring, TX | F | 25000 | 987654321 | 4 | | Jennifer | S | Wallace | 987654321 | 1941-06-20 | 291 Berry, Bellaire, TX | F | 43000 | 888665555 | 4 | | Ramesh | K | Narayan | 666884444 | 1962-09-15 | 975 Fire Oak, Humble, TX | M | 38000 | 333445555 | 5 | | Joyce | A | English | 453453453 | 1972-07-31 | 5631 Rice, Houston, TX | F | 25000 | 333445555 | 5 | | Ahmad | V | Jabbar | 987987987 | 1969-03-29 | 980 Dallas, Houston, TX | M | 25000 | 987654321 | 4 | | James | E | Borg | 888665555 | 1937-11-10 | 450 Stone, Houston, TX | M | 55000 | NULL | 1 | ### Department Information **DEPARTMENT Table:** | Department Name | Department Number | Manager SSN | Manager Start Date | |----------------
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Query Syntax
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education