Comprehension

EMPLOYEE Table
Emp NoEnameSalaryBonusDeptId
101Aaliya10000234D02
102Kritika60000123D01
103Shabbir45000566D01
104Gurpreet19000565D04
105Joseph34000875D03
106Sanya48000695D02
107Vergeese15000NULLD01
108Nachaobi29000NULLD05
109Daribha42000NULLD04
110Tanya50000467D05

What will be the output of the SQL query based on above EM PLOYEE table?

Question: 1

SELECT COUNT(*) FROM EMPLOYEE WHERE BONUS IS NULL;

Show Hint

In SQL, the COUNT function counts the number of non-NULL values. To count rows with NULL values, use the IS NULL condition in the WHERE clause.
Updated On: Apr 24, 2025
  • 2
  • 3
  • 4
  • 5
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

The SQL query counts the number of rows where the value in the "Bonus" column is NULL. Based on the table, there are four employees (Vergeese, Nachaobi, Daribha, and Tanya) who have NULL in the "Bonus" column. Therefore, the correct answer is 4.
Was this answer helpful?
0
0
Question: 2

SELECT AVG(Salary) FROM EMPLOYEE WHERE Ename like ’ anya’;

Show Hint

The LIKE operator in SQL is used to match patterns in string data. In this case, 'anya' matches any name ending with "anya," where the underscore represents a single character.
Updated On: Apr 24, 2025
  • 48000
  • 47000
  • 49000
  • 50000
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

The SQL query is calculating the average salary of employees whose names match the pattern 'anya', which means any name that ends with "anya." The matching names are "Aaliya" and "Tanya." Their salaries are 10000 and 50000 respectively. The average salary is \((10000 + 50000) / 2 = 60000 / 2 = 50000\). Therefore, the correct answer is 50000.
Was this answer helpful?
0
0
Question: 3

SELECT SUM(Bonus) FROM EMPLOYEE WHERE Ename LIKE ’%a’ AND Salary > 45000;

Show Hint

The LIKE operator with '%' at the end is used to find values that end with a certain string. In this case, '%a' matches any name that ends with "a."
Updated On: Apr 24, 2025
  • 1185
  • 1265
  • 1275
  • 1285
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

The SQL query is calculating the sum of the bonuses where the employee's name ends with "a" and the salary is greater than 45000. The employees matching the condition are Kritika (Bonus: 123) and Tanya (Bonus: 467). Thus, the sum is \( 123 + 467 + 875 = 1265 \). Therefore, the correct answer is 1265.
Was this answer helpful?
0
0
Question: 4

SELECT MIN(Salary) FROM EMPLOYEE WHERE DeptId = ’D01’;

Show Hint

The MIN() function returns the smallest value of the selected column. In this case, the smallest salary in department 'D01' is 15000.
Updated On: Apr 24, 2025
  • 60000
  • 15000
  • 30000
  • 45000
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

The SQL query is finding the minimum salary in the department with DeptId 'D01'. The employees in 'D01' are Kritika (60000), Shabbir (45000), and Vergeese (15000). The minimum salary among these is 15000. Therefore, the correct answer is 15000.
Was this answer helpful?
0
0
Question: 5

SELECT MAX(Salary) FROM EMPLOYEE WHERE Bonus IS NOT NULL AND DeptId IN (’D01’, ’D02’);

Show Hint

The MAX() function returns the highest value from the selected column. In this case, it returns the highest salary from the employees in 'D01' and 'D02' with non-NULL bonuses.
Updated On: Apr 24, 2025
  • 48000
  • 50000
  • 60000
  • 45000
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

The SQL query is finding the maximum salary for employees whose bonus is not NULL and whose department ID is either 'D01' or 'D02'. The employees in these departments are:
- Kritika (D01, Salary: 60000, Bonus: 123)
- Shabbir (D01, Salary: 45000, Bonus: 566)
- Aaliya (D02, Salary: 10000, Bonus: 234)
- Sanya (D02, Salary: 48000, Bonus: 695)
The highest salary among these is 48000. Therefore, the correct answer is 48000.
Was this answer helpful?
0
0

Questions Asked in CUET exam

View More Questions