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.
- On which continent is the Great Victoria Desert located?
- Sawai Jai Singh II, commonly known as Sawai Raja Jai Singh, was the 29th ruler of which dynasty in the Kingdom of Amber?
- Where did the Indian Armed Forces conduct Exercise Desert Hunt 2025?
- Which constitutional provision addresses interstate water disputes in India?
Identify the correct statements about the Grameen Bharat Mahotsav:
1. The event was inaugurated by PM Narendra Modi.
2. Its motto is “Se...
- Popir is a traditional dance form of which tribal community of Arunachal Pradesh?
Recently India defeated which country to claim the bronze medal in the 2022 Asian Boys' U18 Volleyball Championship?
What is the theme of Aero India 2025?
Which Indian astronauts were announced by the ISRO in August 2024 as part of the crew for the Axiom-4 mission to the ISS?
A) Shubhanshu Shukla
Select the related word from the given alternatives.
Generous: Stingy :: Brave: ?