ratio_to_report(ziduan) OVER ()

PERCENT_RANK( ) OVER ( window-spec )
计算百分比,会进行迭代,计算方法为 (RANK - 1)/(n-1)。
例:
(1)    SELECT DepartmentID, Surname, Salary, Sex,
    PERCENT_RANK() OVER ( PARTITION BY Sex
      ORDER BY Salary DESC ) AS PctRank
  FROM Employees
  WHERE State IN ( 'NY' );

(2)SELECT Surname, Salary,
     PERCENT_RANK () OVER ( ORDER BY Salary DESC ) "Rank"
     FROM Employees
WHERE State IN ( 'UT', 'AZ' ) AND Sex IN ( 'F' );

(3)SELECT *
FROM ( SELECT Surname, Salary,
       PERCENT_RANK () OVER ( ORDER BY Salary DESC ) "Rank"
       FROM Employees
       WHERE Sex IN ( 'M' )  )
       AS DerivedTable ( Surname, Salary, Percent )
WHERE Percent < 0.05;



而ratio_to_report(ziduan) OVER ()查询的是占总量的百分比,不会进行迭代计算。

你可能感兴趣的:(F#)