Skip to content

Instantly share code, notes, and snippets.

Avatar

Jason McDermott jason-mcdermott

  • Rightpoint Consulting
View GitHub Profile
View Sql group and transform.sql
/*
sql transform this result
A, 1, q
A, 2, r
A, 3, x
B, 1, q
B, 2, q
to this
View SQL Top 2 problem.sql
/*
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)