{"id":299437,"date":"2020-02-28T15:00:41","date_gmt":"2020-02-28T15:00:41","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=299437"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=299437","title":{"rendered":"\u041e\u043a\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u00ab\u0444\u043e\u0440\u0442\u043e\u0447\u043a\u043e\u0439\u00bb \u0438\u043b\u0438 \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0440\u0435\u0439\u043c\u043e\u043c"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/490296\/\"><i><b>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442. 26 \u0444\u0435\u0432\u0440\u0430\u043b\u044f \u0432 OTUS \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u043b\u0438 \u0437\u0430\u043d\u044f\u0442\u0438\u044f \u0432 \u043d\u043e\u0432\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u0435 \u043f\u043e \u043a\u0443\u0440\u0441\u0443 <a href=\"https:\/\/otus.pw\/Xn4d\/\">\u00abMS SQL Server \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u00bb<\/a>. \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u0441\u0432\u043e\u0435\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u043f\u0440\u043e \u043e\u043a\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/b> \u041a\u0441\u0442\u0430\u0442\u0438, \u0432 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0443\u044e \u043d\u0435\u0434\u0435\u043b\u044e \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u0432 \u0433\u0440\u0443\u043f\u043f\u0443 ;-).<\/i><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/vn\/oa\/u-\/vnoau-jary7uq68zxw0rrueyfm8.png\"><\/p>\n<hr>\n<p>  \u041e\u043a\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0447\u043d\u043e \u0432\u043e\u0448\u043b\u0438 \u0432 \u043d\u0430\u0448\u0443 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0443, \u043d\u043e \u043c\u0430\u043b\u043e \u043a\u0442\u043e \u0437\u043d\u0430\u0435\u0442 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0444\u0440\u0435\u0439\u043c\u044b RANGE \u0438 ROWS. <\/p>\n<p>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0436\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f. \u0426\u0435\u043b\u044c \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0443 \u0432\u0430\u0441 \u0442\u043e\u0447\u043d\u043e \u043d\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u201c\u041a\u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0442\u043e?\u201d \u0438 \u201c\u041a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c?\u201d. \u0412\u043e\u043f\u0440\u043e\u0441 \u201c\u0417\u0430\u0447\u0435\u043c?\u201d \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043d\u0435 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u043d\u044b\u043c. <\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0444\u0440\u0435\u0439\u043c, \u0438 \u043a\u0430\u043a \u0441\u0445\u043e\u0436\u0435\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ORDER By \u0432 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0438 OVER().<\/p>\n<p>  \u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430. \u0412\u043e\u043e\u0431\u0449\u0435, \u043e\u0447\u0435\u043d\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u2014 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0438 \u043f\u0440\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0441\u0435\u0431\u044f \u2014 \u0442\u0430\u043a \u0432\u044b \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u0435 \u0431\u0435\u043b\u044b\u0435 \u043f\u044f\u0442\u043d\u0430 \u0432 \u0432\u043e\u0441\u043f\u0440\u0438\u044f\u0442\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u043a\u043e\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u0447\u0438\u0442\u0430\u0435\u0448\u044c \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0422\u0430\u0431\u043b\u0438\u0446\u0430<\/p>\n<pre><code class=\"sql\">Create table sales  (sales_id INT PRIMARY KEY, sales_dt DATETIME2 DEFAULT GETUTCDATE(),  customer_id INT, item_id INT, cnt INT, price_per_item DECIMAL(19,4));  INSERT INTO sales (sales_id, sales_dt, customer_id, item_id, cnt, price_per_item) VALUES (1, '2020-01-10T10:00:00', 100, 200, 2, 30.15), (2, '2020-01-11T11:00:00', 100, 311, 1, 5.00), (3, '2020-01-12T14:00:00', 100, 400, 1, 50.00), (4, '2020-01-12T20:00:00', 100, 311, 5, 5.00), (5, '2020-01-13T10:00:00', 150, 311, 1, 5.00), (6, '2020-01-13T11:00:00', 100, 315, 1, 17.00), (7, '2020-01-14T10:00:00', 150, 200, 2, 30.15), (8, '2020-01-14T15:00:00', 100, 380, 1, 8.00), (9, '2020-01-14T18:00:00', 170, 380, 3, 8.00), (10, '2020-01-15T09:30:00', 100, 311, 1, 5.00), (11, '2020-01-15T12:45:00', 150, 311, 5, 5.00), (12, '2020-01-15T21:30:00', 170, 200, 1, 30.15); <\/code><\/pre>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u2014 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 SUM \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0438 \u0431\u0435\u0437 \u043d\u0435\u0435<\/p>\n<pre><code class=\"sql\">SELECT sales_id, customer_id, count,  SUM(count) OVER () as total, SUM(count) OVER (ORDER BY customer_id) AS cum, SUM(count) OVER (ORDER BY customer_id, sales_id) AS cum_uniq FROM sales ORDER BY customer_id, sales_id;<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/da\/d9\/pz\/dad9pzfa7cz9lvtcx_uj-8iulgs.png\"><\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0435 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u043e \u043b\u0435\u0436\u0430\u0449\u0438\u0435 \u0433\u0440\u0430\u0431\u043b\u0438, \u043a\u0430\u043a \u0432\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0435 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0447\u0442\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u043f\u043e\u0434\u0443\u043c\u0430\u044e\u0442, \u0447\u0442\u043e cum \u0438 cum_uniq \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442? \u0414\u0443\u043c\u0430\u0435\u0442\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e? \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u043e \u043f\u043e\u0442\u043e\u043c\u0443 \u0442\u043e \u0442\u0443\u0442 \u044d\u0442\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0430 \u0442\u0430\u043a \u043b\u0438 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u044d\u0442\u043e \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0434\u0430 \u0435\u0449\u0435 \u043f\u0440\u0438 \u043d\u0435 \u0441\u0442\u043e\u043b\u044c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0439 \u043d\u0435\u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438. <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u043d\u0430\u0448\u0443 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u043e\u0440\u0442\u043e\u0447\u043a\u0443.<\/p>\n<p>  \u0424\u043e\u0440\u0442\u043e\u0447\u043a\u0430, \u0430 \u0442\u043e\u0447\u043d\u0435\u0435 \u0444\u0440\u0435\u0439\u043c \u0431\u044b\u0432\u0430\u0435\u0442 2\u0445 \u0432\u0438\u0434\u043e\u0432 ROWS \u0438 RANGE, \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441 ROWS.<br \/>  \u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0444\u0440\u0435\u0439\u043c\u0430:<\/p>\n<ol>\n<li>\u0412\u0441\u0435, \u0447\u0442\u043e \u0434\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0438\/\u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 \u0438 \u0441\u0430\u043c\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0438<br \/>  BETWEEN UNBOUNDED PRECEDING <br \/>  BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW  <\/li>\n<li>\u0422\u0435\u043a\u0443\u0449\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430\/\u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0438 \u0432\u0441\u0435, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u0435<br \/>  BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING <\/li>\n<li>\u0421 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0443\u043a\u0430\u0437\u0430\u0437\u043d\u0438\u0435\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c (\u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f RANGE)<br \/>  BETWEEN N Preceding AND N Following<br \/>  BETWEEN CURRENT ROW AND N Following<br \/>  BETWEEN N Preceding AND CURRENT ROW  <\/li>\n<\/ol>\n<p>  \u041d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0440\u0435\u0439\u043c \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438.<\/p>\n<p>  \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u201c\u0444\u043e\u0440\u0442\u043e\u0447\u043a\u0443\u201d \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0432\u0441\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435, \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 SUM \u043a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435 \u044d\u0442\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u043e\u0439 ASC<\/p>\n<pre><code class=\"sql\">SELECT sales_id, customer_id, cnt,  SUM(cnt) OVER (ORDER BY customer_id, sales_id) AS cum_uniq, SUM(cnt) OVER (ORDER BY customer_id, sales_id ROWS UNBOUNDED PRECEDING) AS current_and_all_before, SUM(cnt) OVER (ORDER BY customer_id, sales_id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS current_and_all_before2 FROM sales ORDER BY customer_id, sales_id;<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/5s\/xz\/l7\/5sxzl7aiaev0w_psmtrxfgd1uio.png\"><\/p>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0445\u043e\u0447\u0443 \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0435 \u0432 \u043e\u043a\u043d\u0435 (\u0432 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0438 OVER()) \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u043c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0432 \u0441\u0430\u043c\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441, \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u043d \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u043f\u043e\u0434\u0441\u0447\u0435\u0442, \u0435\u0441\u043b\u0438 \u0432\u044b \u0440\u0435\u0448\u0438\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0430\u0441\u0447\u0435\u0442 \u0438 \u0441\u0432\u043e\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/p>\n<pre><code class=\"sql\">SELECT sales_id, customer_id, cnt,  SUM(cnt) OVER (ORDER BY customer_id, sales_id) AS cum_uniq, SUM(cnt) OVER (ORDER BY customer_id, sales_id ROWS UNBOUNDED PRECEDING) AS current_and_all_before, SUM(cnt) OVER (ORDER BY customer_id, sales_id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS current_and_all_before2 FROM sales ORDER BY cnt;<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/9d\/lf\/ad\/9dlfadjsfln70lj_rt0qdcdird4.png\"><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0444\u0440\u0435\u0439\u043c\u0430, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0432\u0441\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. <\/p>\n<pre><code class=\"sql\">SELECT sales_id, customer_id, cnt,  SUM(cnt) OVER (ORDER BY customer_id, sales_id ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS current_and_all_frame, SUM(cnt) OVER (ORDER BY customer_id DESC, sales_id DESC) AS current_and_all_order_desc FROM sales ORDER BY customer_id, sales_id; <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/zb\/4z\/b6\/zb4zb6if36ixgxumfcxue7r-htw.png\"><\/p>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435 \u0442\u0443\u0442 \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043b\u044f \u0430\u0433\u0433\u0440\u0435\u0433\u0430\u0442\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u2014 \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c ROWS \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0435\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0432\u0430\u0448\u0438 \u043f\u043e\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u044e\u0440\u043f\u0440\u0438\u0437 \u0432 \u0432\u0438\u0434\u0435 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. <\/p>\n<p>  \u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u043d\u0435 \u0441\u044b\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u0448\u044c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u043e\u0439\u0442\u0438 \u0432\u043e \u0444\u0440\u0435\u0439\u043c<\/p>\n<pre><code class=\"sql\">SELECT sales_id, customer_id, cnt,  SUM(cnt) OVER (ORDER BY customer_id, sales_id ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS before_and_current, cnt, SUM(cnt) OVER (ORDER BY customer_id, sales_id ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS current_and_1_next, cnt, SUM(cnt) OVER (ORDER BY customer_id, sales_id ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING) AS before2_and_2_next FROM sales ORDER BY customer_id, sales_id;<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/x4\/sw\/h1\/x4swh1lqz6fyyrmxzrxhc_5qhjw.png\"><\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u044b \u0443\u0436\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0435 \u043a\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d, \u0438 \u043e\u043d, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d \u043f\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c. <\/p>\n<h3>\u0420\u0430\u0437\u043d\u0438\u0446\u0430 ROWS \u0438 RANGE<\/h3>\n<p>  \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e ROWS \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u043e\u0439, \u0430 RANGE \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u043c. \u041f\u0440\u0430\u0432\u0434\u0430 \u044d\u0442\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u043d\u043e \u043c\u0430\u043b\u043e \u0447\u0442\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435? <\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 (\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0432\u043d\u0438\u0437\u0443 \u0441\u0442\u0430\u0442\u044c\u0438)<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dx\/ix\/nv\/dxixnvdxihdloazoiw6gqpafr6y.png\"><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rp\/hg\/do\/rphgdok-lyuj0thbkbqektmp2rk.png\"><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0442\u043e \u0441\u0442\u0430\u043d\u0435\u0442 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438. <\/p>\n<p>  \u041a\u0430\u043a \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435 ROWS \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0439, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a RANGE \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432\u0435\u0441\u044c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443 \u0432\u0430\u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0432 ORDER BY \u043e\u043a\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. <\/p>\n<pre><code class=\"sql\">SELECT sales_id, customer_id, cnt,  SUM(cnt) OVER (ORDER BY customer_id) AS cum_uniq, cnt, SUM(cnt) OVER (ORDER BY customer_id ROWS UNBOUNDED PRECEDING) AS current_and_all_before, customer_id, cnt, SUM(cnt) OVER (ORDER BY customer_id RANGE UNBOUNDED PRECEDING) AS current_and_all_before2 FROM sales ORDER BY 2, sales_id;<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/bp\/g9\/gv\/bpg9gv3-kinq8vielngo1aowprq.png\"><\/p>\n<p>  ROWS \u2014 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043d\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u0430, \u0430 \u0432\u043e\u0442 RANGE \u043a\u0430\u043a \u0440\u0430\u0437 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u044b \u043f\u0435\u0440\u0438\u043e\u0434\u044b, \u0441 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u043e\u043b\u0435\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438. \u0412 \u044d\u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 SUM() \u0441 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u043e\u0439 \u043f\u043e \u043d\u0435\u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u043e\u043b\u044e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440. <\/p>\n<pre><code class=\"sql\">SELECT sales_id, customer_id, price_per_item, cnt,  SUM(cnt) OVER (ORDER BY customer_id, price_per_item) AS cum_uniq, cnt, SUM(cnt) OVER (ORDER BY customer_id, price_per_item ROWS UNBOUNDED PRECEDING) AS current_and_all_before, customer_id, cnt, SUM(cnt) OVER (ORDER BY customer_id, price_per_item RANGE UNBOUNDED PRECEDING) AS current_and_all_before2 FROM sales ORDER BY 2, price_per_item;<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/mq\/aw\/h8\/mqawh8dsjdtmhemt1zslc1uisnm.png\"><\/p>\n<p>  \u0422\u0443\u0442 \u0443\u0436\u0435 2 \u043f\u043e\u043b\u044f \u0438 range \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u043c \u0441 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u043e \u043e\u0431\u043e\u0438\u043c \u043f\u043e\u043b\u044f\u043c<\/p>\n<p>  \u0418 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0432 \u0440\u0430\u0441\u0447\u0435\u0442 \u0432\u0441\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 SUM \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u043e\u0439:<\/p>\n<pre><code class=\"sql\">SELECT sales_id, customer_id, price_per_item, cnt,  SUM(cnt) OVER (ORDER BY customer_id DESC, price_per_item DESC) AS cum_uniq, cnt, SUM(cnt) OVER (ORDER BY customer_id, price_per_item ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS current_and_all_before, customer_id, cnt, SUM(cnt) OVER (ORDER BY customer_id, price_per_item RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS current_and_all_before2 FROM sales ORDER BY 2, price_per_item, sales_id desc;<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ms\/dd\/cs\/msddcsrra8xe2brharn8opjnni8.png\"><\/p>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e RANGE \u043e\u043f\u044f\u0442\u044c \u0436\u0435 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432\u0435\u0441\u044c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0445 \u043f\u0430\u0440.<\/p>\n<p>  \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c ROWS \u0438 RANGE \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u043d\u043e\u0432\u0430\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u0436\u0435 \u0435\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0430 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0447\u0435\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f ROWS \u0438 RANGE \u0438 \u0432\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442\u0435 \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u0442 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u0440\u0435\u0439\u043c. <\/p>\n<p>  \u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u043e \u0440\u0430\u0437\u043d\u0438\u0446\u0443 RANGE \u0438 ROWS<br \/>  <a href=\"https:\/\/www.slideshare.net\/marktab\/window-functions-with-sql-server-2016?qid=6839ce73-f143-4ece-b8d7-760751bf62b3&amp;v=&amp;b=&amp;from_search=4\">Window functions with SQL Server 2016, Mark Tabladillo<\/a><\/p>\n<p>  <a href=\"https:\/\/otus.pw\/Xn4d\/\">\u0423\u0441\u043f\u0435\u0442\u044c \u043d\u0430 \u043a\u0443\u0440\u0441<\/a><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/490296\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/490296\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/490296\/\"><i><b>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442. 26 \u0444\u0435\u0432\u0440\u0430\u043b\u044f \u0432 OTUS \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u043b\u0438 \u0437\u0430\u043d\u044f\u0442\u0438\u044f \u0432 \u043d\u043e\u0432\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u0435 \u043f\u043e \u043a\u0443\u0440\u0441\u0443 <a href=\"https:\/\/otus.pw\/Xn4d\/\">\u00abMS SQL Server \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u00bb<\/a>. \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u0441\u0432\u043e\u0435\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u043f\u0440\u043e \u043e\u043a\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/b> \u041a\u0441\u0442\u0430\u0442\u0438, \u0432 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0443\u044e \u043d\u0435\u0434\u0435\u043b\u044e \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u0432 \u0433\u0440\u0443\u043f\u043f\u0443 ;-).<\/i><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/vn\/oa\/u-\/vnoau-jary7uq68zxw0rrueyfm8.png\"><\/p>\n<hr>\n<p>  \u041e\u043a\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0447\u043d\u043e \u0432\u043e\u0448\u043b\u0438 \u0432 \u043d\u0430\u0448\u0443 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0443, \u043d\u043e \u043c\u0430\u043b\u043e \u043a\u0442\u043e \u0437\u043d\u0430\u0435\u0442 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0444\u0440\u0435\u0439\u043c\u044b RANGE \u0438 ROWS. <\/p>\n<p>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0436\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f. \u0426\u0435\u043b\u044c \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0443 \u0432\u0430\u0441 \u0442\u043e\u0447\u043d\u043e \u043d\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u201c\u041a\u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0442\u043e?\u201d \u0438 \u201c\u041a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c?\u201d. \u0412\u043e\u043f\u0440\u043e\u0441 \u201c\u0417\u0430\u0447\u0435\u043c?\u201d \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043d\u0435 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u043d\u044b\u043c. <\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0444\u0440\u0435\u0439\u043c, \u0438 \u043a\u0430\u043a \u0441\u0445\u043e\u0436\u0435\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ORDER By \u0432 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0438 OVER().<\/p>\n<p>  \u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430. \u0412\u043e\u043e\u0431\u0449\u0435, \u043e\u0447\u0435\u043d\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u2014 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0438 \u043f\u0440\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0441\u0435\u0431\u044f \u2014 \u0442\u0430\u043a \u0432\u044b \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u0435 \u0431\u0435\u043b\u044b\u0435 \u043f\u044f\u0442\u043d\u0430 \u0432 \u0432\u043e\u0441\u043f\u0440\u0438\u044f\u0442\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u043a\u043e\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u0447\u0438\u0442\u0430\u0435\u0448\u044c \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-299437","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299437","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=299437"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299437\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}