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.
Which country was stripped of the right to host the under-20 soccer World Cup, which will now be hosted by Argentina?
Consider the following statements regarding the Chhath Festival:
1. Patna district administration decided to deploy drones to manage Chhath Festi...
Which Indian state was ranked at the top in terms of overall environmental performance in the annual data compendium released by Centre for Science and ...
Which regulatory body has approved the stake acquisition in climate technologies' business of Emerson Electric Co by BCP Emerald Aggregator LP?
Lezim is a folk dance form of which state?
Who recently assumed the position of Commandant at the Military Institute of Technology (MILIT) in Pune?
Salsa, a popular partner dance, originated in which country?
According to the World Trade Organization, what is India’s rank among global exporters of agricultural products as of 2023?
Who provided a description of the utilization of handmade paper in the mountainous regions of Garhwal and Kumaon?
On 21st May 2023, where did Prime Minister Narendra Modi address the 76th Session of the World Health Assembly?