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.
In the question given below, three sentences are given with one phrase bold in each. From the options given choose the one with the phrase that can rep...
Traditionally the internet slows down to a trickle, since everybody who are not on the street is likely to be online.
In the questions, a part of the sentence is highlighted. Below are given alternatives to the highlighted part which may improve the sentence. Choose t...
Select the most appropriate phrase to replace the underlined phrase in the given sentence to make it grammatically correct. Select 'No correction requ...
Which of the phrases (A), (B), (C), and (D) given below should replace the phrase given in ’bold’’ in the following sentence to make the sentenc...
News about the surge in Covid-19 cases is broadcasted every morning.
I have to complete all my plans for the week asap so that I can go to the beach and kick back , while eating the ice cream.
Select the alternative that will improve the bold part of the sentence in case there is no improvement select “No improvement”.
In the maj...
In the following questions, sentences are given with a part in bold. The given phrase in bold may or may not contain an error. If a phrase has an error...
 In the questions, a part of the sentence is highlighted. Below are given alternatives to the highlighted part which may improve the sentence. Choose ...