Suppose we have 3 employees in each department.we have total 3 departments . Below is the sample source table
Emp deptno salary A 10 1000 B 10
CREATE TABLE Employee ([Name] varchar(1), [Dept] varchar(1), [Salary] int) ; INSERT INTO Employee ([Name], [Dept], [Salary]) VALUES ('a', 'M', 20), ('b', 'M', 25), ('c', 'M', 30), ('d', 'C', 44), ('e', 'C', 45), ('f', 'C', 46), ('g', 'H', 20)