Information Management: Select From Like
Information Management: Select From Like
Exercise 4
1. QUESTION: Write the SQL code required to list the employee number, last
name, first name, and middle initial of all employees whose last names start
with Smith. In other words, the rows for both Smith and Smithfield should be
included in the listing. Sort the results by employee number. Assume case
sensitivity.
ANSWER:
Ch07_ConstructCo database, write the SQL code that will join the EMPLOYEE and
PROJECT tables using EMP_NUM as the common attribute. Display the attributes
ANSWER:
WHERE employee.EMP_CODE=project.EMP_CODE
ANSWER:
ORDER BY EMP_LNAME
4. QUESTION: Write the SQL code that will list only the distinct project
ANSWER:
ASSIGNMENT table. Your query should retrieve the assignment number, employee
number, project number, the stored assignment charge (ASSIGN_CHARGE), and the
ANSWER:
will yield the total number of hours worked for each employee and the total
charges stemming from those hours worked, sorted by employee number. The
ANSWER:
assignment.ASSIGN_HOURS AS SumOfAssignHour,
ANSWER:
ORDER BY PROJ_CODE
8. QUESTION: Write the SQL code to generate the total hours worked and the
total charges made by all employees. The results are shown in Figure P7.8.
ANSWER: