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 marked price of a product is Rs.240 more than the cost price. If 15% discount offered on the marked price and the profit percent on that product is ...
Ratio of cost price of two items P and Q is 2:5. Item P and Item Q are marked 25% above and 30% above their respective cost price. If the ratio of disco...
The marked price of an article is ₹600. After allowing a discount of 25% on the marked price, there was a loss of ₹30. The loss percentage is:
When a person sold an article, his profit% is 65% of the selling price. If the cost price is increased by 80% and the selling price remains the same, th...
A purchased an article for Rs 1560. She sold the article at 10% profit. She then added Rs 325 to the amount received and purchased a purse such t...
A Shopkeeper sold an article at 20% loss. If he had sold it for Rs. 420/- more, he would have made 40% profit, find the selling price of the article?
- A dealer bought a microwave for Rs. 4,000 and a blender for Rs. 1,500. He increased their prices by 25% and 10% respectively. If both items were sold toget...
- A shopkeeper sold an item at a 20% profit. If he had purchased it for Rs. 400 less and sold it for Rs. 240 more, his profit margin would have increased to ...
A bought an article at 20% less of the marked price and sold it at 12% more than the marked price. Find the profit earned by him.
An article is sold at a profit of 40%. If the purchasing price triples and the selling price decreases by 20%, what will be the percentage of profit or ...