If we execute the given query in SQL SERVER 2014 .
SELECT ID, NAME, SUM(SALARY) As Salary FROM EMPLOYEE
Error Message :
but getting the below error.
Msg 8120, Level 16, State 1, Line 1
Column 'EMPLOYEE.ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Causes:
You are trying to calculate sum of salary without using “Group By” Clause. If aggregate functions are using in SELECT statement , Group BY calculate a summary value for each group.
Solution of the Error:
Use the GROUP BY Clause to calculate the Salary of Employee. Write below statement to get the correct result.
SELECT ID, NAME, SUM(SALARY) As Salary FROM EMPLOYEE
GROUP BY ID, NAME
Output :
ID NAME Salary
1 AMIT 10000
6 Manuj 40000
7 Ajun 35000
If you want to sell your readymade software to the genuine clients or businessman, list your software with details and demo links.
Clients will find it using our advanced search filter and will contact you directly.
No any charge for the product lsiting.