4,820
社区成员
发帖
与我相关
我的任务
分享
if OBJECT_ID('T_UserProductSale','U') IS NOT NULL
DROP TABLE T_UserProductSale
GO
CREATE TABLE T_UserProductSale
(
UserId nvarchar(5),
WorkHour float default(0),
ProductType nvarchar(5),
ProductSubType nvarchar(10),
SaleSum float default(0)
)
insert T_UserProductSale(UserId,ProductType,ProductSubType,SaleSum)
select N'USER1',N'P1',N'P1_SUB1',1 UNION ALL
select N'USER1',N'P1',N'P1_SUB2',2 UNION ALL
select N'USER1',N'P2',N'P2_SUB1',0 UNION ALL
select N'USER1',N'P2',N'P2_SUB2',0 UNION ALL
select N'USER2',N'P2',N'P2_SUB1',10 UNION ALL
select N'USER2',N'P2',N'P2_SUB2',20 UNION ALL
select N'USER2',N'P1',N'P1_SUB1',0 UNION ALL
select N'USER2',N'P1',N'P1_SUB2',0
SELECT *
FROM T_UserProductSale 

