Question
Which of the following SQL queries is used to find the
second highest salary from an employee table? SELECT MAX (salary) Â Â Â Â Â Â Â FROM employee WHERE salary < ( SELECT MAX (salary) FROM employee);Solution
The query uses a nested SELECT statement to retrieve the second-highest salary from the employee table. Let's break it down:
- Inner query: SELECT MAX(salary) FROM employee retrieves the highest salary in the employee table.
- Outer query: The WHERE salary < (SELECT MAX(salary) FROM employee) ensures that only those salaries smaller than the highest salary are considered, and the outer MAX(salary) retrieves the largest salary from that set, effectively giving the second-highest salary.
- B is incorrect because the query does not return the highest salary but rather the second-highest salary by excluding the maximum salary.
- C is incorrect because nested SELECT statements are valid in SQL and do not cause errors here.
- D is incorrect because the query will return a value unless there are no records in the employee table.
- E is incorrect because the query will return a single value—the second-highest salary.
Under the Digital India Mission, which of the following initiatives focuses on providing high-speed broadband connectivity to rural and remote areas of...
How many traditional trades are initially covered under the 'PM Vishwakarma Yojana'?
Consider the following Statements.
(I) WPI tracks inflation at the wholesale level and CPI captures changes in prices levels at the consumer l...
What is the significance of geo-tagging assets under the e-Panchayat Mission Mode Project (MMP)?
The PM Vishwakarma scheme also includes a dedicated portal for:
One of the sub-schemes of SMILE is Central Sector Scheme for Comprehensive Rehabilitation for Welfare of Transgender Persons. Which of the following is ...
What is the Objective of Swacchta Udyami Yojana
What are the components of the Digital Public Infrastructure (DPI) framework in India, and how has it influenced the fintech sector?
i.   �...
According to economic survey 2022-23............percentage of population lives in rural areas and out of this population 47% is engaged in _____________
What is the main objective of the Montreal Protocol?