开窗函数over select orderid, custid, val, SUM(val) over() as totalvalue, SUM(val) over(partition by custid) as custtotalvalue from Sales.OrderValues select orderid, custid, val, . * val / SUM(val) over() as pctall, . * val / SUM(val) over(partition by cu…