CBSE Class 12 Informatics Practices Question 60 of 90

Querying Using SQL — Question 10

Back to all questions
10
Question

Question 10

Harjat has created the table EMP in his database.

Table : EMP

E_IDNameDeptComm
E001DityaAdmin35000
E002UzairProduction42500
E003RajnikantAdmin21000
E004MoushamiSales23575
E005SamanthaSales37000
E006SunderAdmin43000

Now he wants to find the sum of commission earned by each department. He has executed the following query :

SELECT dept, sum(comm)
GROUP BY dept
FROM EMP;

But, he got an error. Rewrite the correct query after identifying the error(s).

Answer

The error in Harjat's query is the order of the clauses. The GROUP BY clause should come after the FROM clause. The corrected query is as follows :

SELECT dept, sum(comm)
FROM EMP
GROUP BY dept;