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.
Which computer part is responsible for storing data permanently, even when the power is turned off?
A car travels a distance of 240 km in 4 hours. If it increases its speed by 20 km/h for the next 3 hours, how much distance will it cover in total?
Anoop has a specific number of ₹10 coins and ₹5 coins. The total number of coins is 37, and the number of ₹10 coins is 13 l...
What is the % increase in the total number of shoes sold by Seller 'C' over the four days compared to the total number sold by Se...
Rajesh spent 30% and 25% of his monthly salary on food and rent, respectively. Of the remaining amount, he gave 20% and 40% to his mother and brother, r...
If a line has direction ratios 2, -1, -2, determine its direction cosines.
Compute P(A∩B), if P(B) = 0.8 and P(AǀB) = 0.35
I). p 2  – 17p + 70 = 0
II). q 2  – 25q + 154 = 0