Question
Which of the following SQL queries will return the
second highest salary from a table Employee with columns Name and Salary?Solution
This query uses a subquery to find the maximum salary and excludes it using NOT IN. The outer query then finds the maximum salary among the remaining values, effectively identifying the second highest salary. • Why this works: The subquery isolates the highest salary. The outer query ensures the second highest value is identified without requiring an OFFSET. This method works across most SQL systems and avoids platform-specific syntax like LIMIT or TOP. ________________________________________ Why Other Options Are Incorrect: 1. LIMIT 2: Returns two highest salaries but doesn’t isolate the second highest. 2. OFFSET 1: Many SQL platforms do not support LIMIT ... OFFSET or require modifications for accurate execution. 3. DISTINCT Salary: Redundant use of DISTINCT, which is unnecessary when ORDER BY already ensures unique ordering. 4. TOP 2: TOP is SQL Server-specific and requires additional filtering for the second value.
- The given question has one blank indicating that something has been omitted. Choose the word for the given options that could fit in the blank correctly. <...
In the given question a sentence is given with a blank and you have to choose an appropriate word from the given options that can fill the sentence mak...
Major risks from climate change, ________ as extreme weather phenomena, loss of agriculture, water stress and harm to human health, pose a threat to mil...
The spirit of tennis has long ____________ the conflicting worlds of nationalism and globalism.
Choose the correct answer to fill the given blank
The teacher asked the students _____ their homework.
(i) The Constitution (Sixty-first Amendment) Act, 1989 has __________ the voting age from 21 years to 18 years for the Lok Sabha and the Legislative Ass...
India must choose what ______________ its energy mix.
I. Will consist of
II. Will make
III. Will comprise
Fill in the blanks with appropriate words from the alternatives given below each sentence.
He advised me, “You had better ______ now”.
CPR is not only effective while saving someone from drowning. It is also the most vital first aid that can be offered to anyone who is fainting or has s...
In its ……….. to conserve the elusive snow leopard, India has found an unlikely ………. in Kyrgyzstan.