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.
According to Article 22 of the Indian constitution, what is the maximum duration for which someone can be detained under preventive detention without t...
Who appoints the Comptroller and Auditor General of India?
Consider the following statements:
I. As per the Constitution of India, the number of seats assigned to each of the States in the Rajya Sabha is ...
The Right to Freedom of Religion in the Indian Constitution is covered under how many articles?
Which Article of the Indian Constitution states that no person shall be deprived of their property except by authority of law?Â
What is the maximum strength of the Public Accounts Committee of the Lok Sabha?
Which of the following articles of the Indian Constitution pertains to the "High Courts for States"?
Which article of the Indian Constitution deals with the formation of new states and alteration of areas, boundaries, or names of existing states?
Who is known as the guardian and final interpreter of the constitution?
Which body is responsible for conducting elections to the offices of the President and Vice President of India?