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.
P + Q means ‘P is the brother of Q’, P - Q means ‘P is the daughter of Q’, P ÷ Q means ‘P is the husband of Q’, P × Q means ‘P is the so...
‘W + X’, means ‘W is the sister of X’
‘W - X’, means ‘W is the daughter of X’
‘W × X’, means ‘W is the brother...
P + Q means ‘P is the brother of Q’, P - Q means ‘P is the daughter of Q’, P ÷ Q means ‘P is the husband of Q’, P × Q means ‘P is the s...
Answer the following question based on the direction given below. If ‘A#B’ means ‘A is father of B’ ‘A@B’ means ‘A is daughter of B’ ‘...
If ' Y $ I @ W, I # T % S, I % P' , then how is Y related to S?
'A # B' means 'A is the brother of B'. 'A @ B' means 'A is the daughter of B'. 'A & B' means 'A is the husband of B'. 'A % B' means 'A is the wife of B'...
If "G @ P & I % W & V # Q & K * M" is definitely true, then how is W related to K?
Answer the following question based on the direction given below.
If 'A#B' means 'A is father of B'
'A@B' means 'A is brother of B'
How is J related to N’s father?
If 'A # B' means 'A is mother of B', 'A @ B' means 'A is brother of B', 'A % B' means 'A is sister of B', 'A $ B' means 'A is father of B'. In expressio...