Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write the SQL to list all attributes in the order in which they are stored in

ID: 3624631 • Letter: 1

Question

1. Write the SQL to list all attributes in the order in which they are stored in the table and all rows from the EMPLOYEE table sorting the rows by EMP_LNAME and then EMP_FNAME both in ascending order.


3. Write the SQL to list all attributes from the ASSIGNMENT table that were assigned on March 5, 2004. There is no specific order of rows for this problem.


6. Write the SQL to list the attributes ASSIGN_NUM, ASSIGN_HOURS from the ASSIGNMENT table. There is no specific order of rows for this problem.

7. Write the SQL to list the attribute ASSIGN_NUM from the ASSIGNMENT table. Use the aggregate function SUM to total the ASSIGN_HOURS for each ASSIGN_NUM in the table. There is no specific order of rows for this problem.


8. Are the results the same or different in problems #6 and problem #7? Why or why not?

9. Write the SQL to list the attribute ASSIGN_DATE from the ASSIGNMENT table. Use the aggregate function SUM to total the ASSIGN_HOURS for each ASSIGN_DATE in the table. Sort the rows by date with most recent date first.

10. Write the SQL to list the attribute ASSIGN_DATE from the ASSIGNMENT table. Use the aggregate function SUM to total the ASSIGN_HOURS for each ASSIGN_DATE in the table. Limit the rows returned to those with the total ASSIGN_HOURS greater than 10. Sort the rows by date by the SUM of the ASSIGN_HOURS in descending order.

Explanation / Answer

Dear user, 1. SELECT   EMP_LNAME,EMP_FNAME from EMPLOYEE ORDER BY EMP_LNAME ASC,EMP_FNAME ASC; 3. SELECT *FROM ASSIGNMENT; 6. SELECT ASSIGN_NUM, ASSIGN_HOURS FROM ASSIGNMENT; 7. SELECT ASSIGN_NUM, SUM(ASSIGN_HOURS) AS ASSIGN_HOURS_TOTAL FROM ASSIGNMENT; 8. Problem 6 display result is ASSIGN_NUM, ASSIGN_HOURS and problem 7 display result is ASSIGN_NUM,ASSIGN_HOURS_TOTAL (display total ASSIGN_HOURS). So, result is different in problem6 and problem 7. 9. SELECT ASSIGN_DATE, SUM(ASSIGN_HOURS) AS ASSIGN_HOURS_TOTAL
FROM ASSIGNMENT;
10. SELECT ASSIGN_DATE, SUM(ASSIGN_HOURS) AS ASSIGN_HOURS_TOTAL
FROM ASSIGNMENT;
WHERE ASSIGN_HOURS_TOTAL > 10 ORDER BY ASSIGN_DATE DESC;
EMP_LNAME ASC,EMP_FNAME ASC; 3. SELECT *FROM ASSIGNMENT; 6. SELECT ASSIGN_NUM, ASSIGN_HOURS FROM ASSIGNMENT; 7. SELECT ASSIGN_NUM, SUM(ASSIGN_HOURS) AS ASSIGN_HOURS_TOTAL FROM ASSIGNMENT; 8. Problem 6 display result is ASSIGN_NUM, ASSIGN_HOURS and problem 7 display result is ASSIGN_NUM,ASSIGN_HOURS_TOTAL (display total ASSIGN_HOURS). So, result is different in problem6 and problem 7. 9. SELECT ASSIGN_DATE, SUM(ASSIGN_HOURS) AS ASSIGN_HOURS_TOTAL
FROM ASSIGNMENT;
10. SELECT ASSIGN_DATE, SUM(ASSIGN_HOURS) AS ASSIGN_HOURS_TOTAL
FROM ASSIGNMENT;
WHERE ASSIGN_HOURS_TOTAL > 10 ORDER BY ASSIGN_DATE DESC;