declare @sometable table (
id int identity,
col1 int,
col2 int,
col3 int,
col4 int
)
insert into @sometable
select 1, 2, 3, 4 union all
select 5, 6, 7, 8
; WITH CTE AS (
SELECT col1, col2, col3, col4
FROM @sometable
)
SELECT * from CTE
union all
select SUM(col1), SUM(col2), SUM(col3), SUM(col4)
FROM CTE
|