Example: Window frame comparing ROWS and RANGE

This query compares ROWS and RANGE. The data contain duplicate ROWS per the ORDER BY clause.

SELECT prod_id, month_num, sales, SUM(sales) OVER 
  (ws1 RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) AS
    Range_sum, SUM(sales) OVER
  (ws1 ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) AS
    Row_sum 
FROM sale window ws1 AS (PARTITION BY prod_id ORDER BY
  month_num) 
ORDER BY prod_id, month_num;

The results from the above query:

prod_id  month_num   sales   Range_sum   Row_sum
-------  ---------   -----   ----------  -------
10               1     100         250       100
10               1     150         250       250
10               2     120         370       370 
10               3     100         470       370
10               4     130         350       350
10               5     120         381       350
10               5      31         381       281
10               6     110         391       261
20               1      20          20        20
20               2      30          50        50
20               3      25          75        75
20               4      30          85        85
20               5      31          86        86
20               6      20          81        81
30               1      10          10        10
30               2      11          21        21
30               3      12          33        33
30               4       1          25        24
30                4        1           25         14