This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Given a table of employees and salaries | |
find the second-highest paid employee | |
*/ | |
DECLARE @Temp TABLE (EmployeeId INT, Salary INT) | |
INSERT INTO @Temp VALUES (1, 100000) | |
INSERT INTO @Temp VALUES (2, 110000) | |
INSERT INTO @Temp VALUES (3, 120000) | |
INSERT INTO @Temp VALUES (4, 130000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
sql transform this result | |
A, 1, q | |
A, 2, r | |
A, 3, x | |
B, 1, q | |
B, 2, q | |
to this |