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.
Find the remainder when the number (196n + 75) is divided by 14.
There are five numbers A, B, C, D and E. The ratio between the numbers of B and D is (y+1) : 3 respectively. The number C is 12.5% more than the number ...
Sum of squares of three consecutive numbers is 1589. Find the sum of first and third number.
The arithmetic mean of two values ‘a’ and ‘b’ is 16, and their geometric mean is 10√2. Find the positive difference between the numbers, given...
Find the difference between of the greatest among the numbers 0.82, 0.802, 0.85, 0.085 with the smallest among the numbers 0.3, 0.03, 0.203, 2.03
A bag contains coins of ₹1, ₹2, and ₹5 denominations in the ratio 5:2:3, respectively. If the total value of the coins is ₹1,224, how many ₹5 ...
Find the range of the given data:
65, 85, 45, 20, 35, 90, 100, 60, 55
What is the ratio of the sum of the squares of the first 8 natural numbers to the sum of the first 12 odd natural numbers?
A number exceeds 45 times its reciprocal by 5/6. Find the number.
Find the sum of the first 40 natural numbers.