DECLARE @EMP TABLE (
EmployeeName VARCHAR(20),
Department VARCHAR(10),
Salary MONEY
)
INSERT INTO @EMP (EmployeeName, Department, Salary)
SELECT 'Jacob', 'IT', 25000 UNION ALL
SELECT 'Mike', 'IT', 35000 UNION ALL
SELECT 'Steve', 'Marketing', 20000 UNION ALL
SELECT 'Smith', 'Marketing', 22000
select * from @EMP
SELECT
Department,
MAX(Salary) AS HighestSalary
FROM @EMP
GROUP BY Department
EmployeeName VARCHAR(20),
Department VARCHAR(10),
Salary MONEY
)
INSERT INTO @EMP (EmployeeName, Department, Salary)
SELECT 'Jacob', 'IT', 25000 UNION ALL
SELECT 'Mike', 'IT', 35000 UNION ALL
SELECT 'Steve', 'Marketing', 20000 UNION ALL
SELECT 'Smith', 'Marketing', 22000
select * from @EMP
SELECT
Department,
MAX(Salary) AS HighestSalary
FROM @EMP
GROUP BY Department