COMPUTE BY 子句 cube 子句
declare @Temp TABLE (
pid INT PRIMARY KEY IDENTITY(1,1),
name VARCHAR(100),
color VARCHAR(50),
num INT
)
INSERT INTO @Temp(name,color,num)
SELECT 'ball','red',12
UNION ALL
SELECT 'ball','red',24
UNION ALL
SELECT 'cat','yellow',13
UNION ALL
SELECT 'ball','yellow',13
UNION ALL
SELECT 'dog','yellow',13
UNION ALL
SELECT 'cat','black',4
UNION ALL
SELECT 'cat','white',5
select * from @Temp