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.
A boat can cover 84 km upstream and 252 km downstream in 14 hours. Speed of the stream is how much less than the speed of the boat in still water if the...
A man can row 25/2 km an hour in still water and he finds that it takes him thrice as long to row up as to row down the river. The rate of stream is:
A man rows 240 km upstream in 5 hours and 360 km downstream in 5 hours. Find the time required to row 300 km in still water.
A boat covers a distance of 240 km downstream in 8 hours. If the ratio of upstream speed to downstream speed of the boat is 2:5, then find the distance ...
The ratio of the speed of boat ‘A’ in still water, the speed of boat ‘B’ in still water and the speed of the current is 6:4:2, respectively. If ...
A boat travels 42 km against the current and 72 km with the current in a total time of 8 hours. Additionally, it covers a distance of 56 km in still wat...
The ratio between the speed of the boat in upstream and the speed of the stream are 6:5 respectively. The boat can cover (d+140) km distance in downstre...
The ratio of speed of the boat and the speed of the current is 6:5. If the downstream speed of the boat is 44 km/hr. Then find how much distance will th...
If a river is flowing at a rate of 6 km/hr and a boat's speed in still water is 150% higher than the river's speed, and the boat travels 'd' kilometers ...
The ratio of the speed of boat in upstream to speed of boat in downstream is 7:9. If the boat can cover a total of 70 km upstream and 144 km downstream ...