说明:本文测试时使用的是在线测试环境http://www.sqlfiddle.com/,SQL Server的版本为SQL Server 2017
构建测试所用产品销售信息表sales_info:
-- 创建产品销售信息表
create table sales_info(
pro_type varchar(5),
pro_name char(5),
pro_sale decimal(9,2),
pro_date date)
-- sales_info的字段中pro_type表示产品类型,pro_name表示产品名称,
-- pro_sale表示产品销售额,pro_date表示产品销售日期
-- 向产品销售信息表sales_info中插入数据
insert into sales_info values('p1','AAA',391050.20,'2019-06-01')
insert into sales_info values('p1','AAA',323080.20,'2019-06-02')
insert into sales_info values('p1','ABA',365100.50,'2019-06-03')
insert into sales_info values('p1','BAA',398040.30,'2019-06-04')
insert into sales_info values('p1','AAC',341050.80,'2019-06-05')
insert into sa