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

1st question on Chegg, I\'m stuck, please help.. I\'m at a loss on 48 and I keep

ID: 3539217 • Letter: 1

Question

1st question on Chegg, I'm stuck, please help.. I'm at a loss on 48 and I keep getting an error on 58. I've double checked everything and before I start ripping through my tables I would like to ensure this is correct....

48. Write a query to display the employee the employee number, last name, first name, salary %u201Cfrom%u201D date, salary end date, and salary amount for employees 83731, 83745, and 84039. Sort the output by employee number and salary %u201Cfrom date.

58.       Write a query to display the customer code, first name, last name, and sum of all invoice totals for customers with cumulative invoice totals greater than $1,500. Sort the output by the sum of invoice totals in descending order.

SELECT [Cust_Code], [Cust_Fname], [Cust_Lname], [Inv_Total], SUM(Inv_Total) AS "TOTAL INVOICES"
FROM LGCUSTOMER, LGINVOICE
GROUP BY [Inv_Total]
HAVING SUM(Inv_Total) > $1500

Error:

Msg 8120, Level 16, State 1, Line 1
Column 'LGCUSTOMER.Cust_Code' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.


I couldn't load the pics, but here are the links. Thanks for any advice

http://i.imgur.com/8fzQH89.gif

http://i.imgur.com/7aiIVhk.gif



Explanation / Answer

SELECT *

FROM (TABLE_NAME)

WHERE EMP_NUM = '83731', '83745','84039'

ORDER BY EMP_NUM, SAL_AMOUNT

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote