SQL · Question 10 · Medium
SQL question 10
Table Employee:
id | name | dept | salary
1 | Asha | HR | 30000
2 | Ravi | IT | 50000
3 | Neha | IT | 60000
4 | Karan | Sales | NULL
5 | Priya | HR | 45000
6 | Vikram | IT | 50000
What does this query return?
SELECT SUM(salary), AVG(salary)
FROM Employee
WHERE dept IN ('HR', 'Sales');
- 75000 and 37500
- 75000 and 25000
- NULL and NULL
- 75000 and NULL
Answer and explanation
Answer: A. 75000 and 37500
Explanation: The rows are Asha 30000, Priya 45000 and Karan NULL. SUM and AVG both ignore the NULL, so SUM = 75000 and AVG = 75000 / 2 = 37500, not 75000 / 3.
Previous: Using a table Employee(id, name, dept, salary), which of the following queries… · Next: Table Employee: id | name | dept | salary 1 | Asha | HR | 30000 2 | Ravi | IT…
Practise sql
Try a fresh set of sql questions with an explanation after every answer, free and without signing up: SQL practice. Or sit a full placement mock test.
More sql questions
- Table Employee: id | name | dept | salary 1 | Asha | HR | 30000 2 | Ravi | IT…
- Table Employee: id | name | dept | salary 1 | Asha | HR | 30000 2 | Ravi | IT…
- Using a table Employee(id, name, dept, salary), which of the following queries…
- Table Employee: id | name | dept | salary 1 | Asha | HR | 30000 2 | Ravi | IT…
- Table Employee: id | name | dept | salary 1 | Asha | HR | 30000 2 | Ravi | IT…
- Table Employee: id | name | dept | salary 1 | Asha | HR | 30000 2 | Ravi | IT…
- Table A has one column x with rows: 1, 1, 2, NULL Table B has one column x…
- Table A has one column x with rows: 1, 1, 2, NULL Table B has one column x…
- Which keyword is written after SELECT to remove duplicate rows from a query's…
- In a LIKE pattern, which wildcard matches exactly one character?
More technical & programming practice
Operating Systems · Computer Networks · Software Engineering · Cloud & DevOps · GenAI Basics · Pseudo-code · C Programming · Java
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge