没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
CONSTRUCTCO O
1. 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.
SELECT EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL
FROM EMPLOYEE
WHERE EMP_LNAME LIKE '%Smith%'
ORDER BY EMP_NUM;
2. Using the EMPLOYEE, JOB, and PROJECT tables in the 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 shown in the results presented in Figure P7.2, sorted by project value.
SELECT PROJ_NAME, PROJ_VALUE, PROJ_BALANCE,
EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMPLOYEE.JOB_CODE,
JOB_DESCRIPTION, JOB_CHG_HOUR
FROM PROJECT, EMPLOYEE, JOB
WHERE EMPLOYEE.EMP_NUM = PROJECT.EMP_NUM
AND JOB.JOB_CODE = EMPLOYEE.JOB_CODE
ORDER BY PROJ_VALUE;
SELECT PROJ_NAME, PROJ_VALUE, PROJ_BALANCE,
E.EMP_LNAME, EMP_FNAME, EMP_INITIAL, E.JOB_CODE,
J.JOB_DESCRIPTION, J.JOB_CHG_HOUR
FROM PROJECT AS P
INNER JOIN EMPLOYEE AS E ON E.EMP_NUM = P.EMP_NUM
INNER JOIN JOB AS J ON J.JOB_CODE = E.JOB_CODE
ORDER BY PROJ_VALUE;
3. Write the SQL code that will produce the same information that was shown in Problem 2, but sorted
by the employee’s last name.
SELECT PROJ_NAME, PROJ_VALUE, PROJ_BALANCE,
EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMPLOYEE.JOB_CODE,
JOB_DESCRIPTION, JOB_CHG_HOUR
FROM PROJECT, EMPLOYEE, JOB
WHERE EMPLOYEE.EMP_NUM = PROJECT.EMP_NUM
AND JOB.JOB_CODE = EMPLOYEE.JOB_CODE
ORDER BY EMP_LNAME;
SELECT PROJ_NAME, PROJ_VALUE, PROJ_BALANCE,
E.EMP_LNAME, EMP_FNAME, EMP_INITIAL, E.JOB_CODE,
J.JOB_DESCRIPTION, J.JOB_CHG_HOUR
FROM PROJECT AS P
INNER JOIN EMPLOYEE AS E ON E.EMP_NUM = P.EMP_NUM
INNER JOIN JOB AS J ON J.JOB_CODE = E.JOB_CODE
ORDER BY E.EMP_LNAME;
4. Write the SQL code that will list only the distinct project numbers in the ASSIGNMENT table, sorted
by project number.
SELECT DISTINCT PROJ_NUM
from ASSIGNMENT
ORDER BY PROJ_NUM;
5. Write the SQL code to validate the ASSIGN_CHARGE values in the ASSIGNMENT table. Your
query should retrieve the assignment number, employee number, project number, the stored
assignment charge (ASSIGN_CHARGE), and the calculated assignment charge (calculated by
multiplying ASSIGN_CHG_HR by ASSIGN_HOURS). Sort the results by the assignment number.
SELECT ASSIGN_NUM, EMP_NUM, PROJ_NUM, ASSIGN_CHARGE,
ASSIGN_CHG_HR * ASSIGN_HOURS AS CACLUATED_ASSIGN_CHARGE
FROM ASSIGNMENT
ORDER BY ASSIGN_NUM;
SELECT ASSIGN_NUM, E.EMP_NUM, P.PROJ_NUM, A.ASSIGN_CHARGE,
(A.ASSIGN_CHG_HR * A.ASSIGN_HOURS) AS CALC_ASSIGN_CHARGE
FROM PROJECT AS P
INNER JOIN EMPLOYEE AS E ON E.EMP_NUM = P.EMP_NUM
INNER JOIN ASSIGNMENT AS A ON A.PROJ_NUM = P.PROJ_NUM;
6. Using the data in the ASSIGNMENT table, write the SQL code that 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 results of running that query are shown in Figure P7.6.
SELECT ASSIGNMENT.EMP_NUM, EMP_LNAME,
SUM(ASSIGNMENT.ASSIGN_HOURS) AS SumOfASSIGN_HOURS,
SUM(ASSIGNMENT.ASSIGN_CHG_HR*ASSIGNMENT.ASSIGN_HOURS) AS SumOfASSIGN_CHARGE
FROM EMPLOYEE, ASSIGNMENT
WHERE EMPLOYEE.EMP_NUM = ASSIGNMENT.EMP_NUM
GROUP BY ASSIGNMENT.EMP_NUM, EMP_LNAME
ORDER BY ASSIGNMENT.EMP_NUM;
SELECT A.EMP_NUM, E.EMP_LNAME, ROUND(Sum(A.ASSIGN_HOURS), 2) AS SumOfASSIGN_HOURS,
ROUND(Sum(A.ASSIGN_CHARGE),2) AS SumOfASSIGN_CHARGE
FROM EMPLOYEE AS E
INNER JOIN ASSIGNMENT AS A On E.EMP_NUM = A.EMP_NUM
GROUP BY A.EMP_NUM, E.EMP_LNAME;
7. Write a query to produce the total number of hours and charges for each of the projects represented
in the ASSIGNMENT table, sorted by project number. The output is shown in Figure P7.7.
SELECT PROJ_NUM,
SUM(ASSIGN_HOURS) AS SumOfASSIGN_HOURS,
SUM(ASSIGN_CHARGE) AS SumOfASSIGN_CHARG
FROM ASSIGNMENT
GROUP BY PROJ_NUM
ORDER BY PROJ_NUM;
SELECT PROJ_NUM,
SUM(ASSIGN_HOURS) AS SumOfASSIGN_HOURS,
SUM(ASSIGNMENT.ASSIGN_CHG_HR*ASSIGNMENT.ASSIGN_HOURS) AS SumOfASSIGN_CHARGE
FROM ASSIGNMENT
GROUP BY PROJ_NUM
ORDER BY PROJ_NUM;
8. 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.
SELECT SUM(ASSIGN_HOURS)AS SumOfASSIGN_HOURS,
SUM(ASSIGN_CHARGE) AS SumOfASSIGN_CHARGE
FROM ASSIGNMENT;
剩余7页未读,继续阅读
资源评论
_djinn
- 粉丝: 7
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于Arduino和Firebase的智能家庭管理系统NodeSmartHome.zip
- (源码)基于C++的East Zone DSTADSO Robotics Challenge 2019机器人控制系统.zip
- (源码)基于Arduino平台的焊接站控制系统.zip
- (源码)基于ESPboy系统的TZXDuino WiFi项目.zip
- (源码)基于Java的剧场账单管理系统.zip
- (源码)基于Java Swing的船只资料管理系统.zip
- (源码)基于Python框架的模拟购物系统.zip
- (源码)基于C++的图书管理系统.zip
- (源码)基于Arduino的简易温度显示系统.zip
- (源码)基于Arduino的智能电动轮椅系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功