KnowledgeBoat Logo
|

Informatics Practices

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).

SQL Queries

2 Likes

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;

Answered By

1 Like


Related Questions