TSQL Min, Max, AVG and Last Value in single query

declare @MyTable table ( SN INT ,[Month] INT ,Acc INT ,Bal INT ) — GO INSERT INTO @MyTable VALUES (1, 7, 101, 1000), (2, 7, 101, 800), (3, 7, 101, 1700), (4, 8, 101, 1200), (5, 8, 101, 900), (6, 9, 101, 2500) — GO select distinct Acc, [Month], MinBal, AvgBal, MaxBal, LastVal from ( …

TSQL Min, Max, AVG and Last Value in single query Read More »