一、建表语句 CREATE TABLE student_2008 ( name VARCHAR ( 32 ), sale INT ); insert into student_2008(name,sale) values ('产品A',90), ('产品B',84), ('产品C',73), ('产品D',100), ('产品E',103), ('产品F',89);
二、需求:计算合计销售额占全体销售额85% 2.1 取全体销售额 select name, sale, sum(sale) over() as alsale from student_2008 --求总销售额

2.2 计算占比 select name, sale, sale/sum(sale) over() as zhbi from student_2008

换个方式计算占比 使用子查询也是这样 就 |