CBSE Class 12 Informatics Practices
Question 60 of 90
Querying Using SQL — Question 10
Back to all questions 10
Question Harjat has created the table EMP in his database.
Table : EMP
| E_ID | Name | Dept | Comm |
|---|---|---|---|
| E001 | Ditya | Admin | 35000 |
| E002 | Uzair | Production | 42500 |
| E003 | Rajnikant | Admin | 21000 |
| E004 | Moushami | Sales | 23575 |
| E005 | Samantha | Sales | 37000 |
| E006 | Sunder | Admin | 43000 |
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).
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;