{"id":342326,"date":"2022-12-08T15:03:51","date_gmt":"2022-12-08T15:03:51","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=342326"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2022-12-08T15:03:51","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=342326","title":{"rendered":"<span>\u041c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u0445\u043e\u0434\u043e\u0432 \u043e\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0435\u0441\u044c \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 SaaS-\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u044f\u0442\u0438\u0438 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043a\u043e\u043c\u043c\u0435\u0440\u0446\u0438\u0438 \u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438, \u0432\u0430\u0441 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0441\u044f\u0442 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u043a\u0430\u043a \u043e\u0442\u0442\u043e\u043a, \u0430\u043f\u0433\u0440\u0435\u0439\u0434\u044b \u0438 \u0434\u0430\u0443\u043d\u0433\u0440\u0435\u0439\u0434\u044b. \u0414\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0431\u0438\u0437\u043d\u0435\u0441\u0443 \u043f\u043e\u043d\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>\u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u0430\u0448\u0435\u0439 \u0430\u0431\u043e\u043d\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0431\u0430\u0437\u044b \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0434\u043b\u0435\u043d\u0438\u0439 (\u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u044b \u0430\u043c\u043e\u0440\u0442\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0435 \u0434\u043e\u0445\u043e\u0434\u044b \u043f\u043e \u043c\u0435\u0441\u044f\u0446\u0430\u043c).<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u043e\u0445\u043e\u0434\u043e\u0432: \u043d\u043e\u0432\u044b\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u044b, \u0430\u043f\u0433\u0440\u0435\u0439\u0434\u044b, \u0434\u0430\u0443\u043d\u0433\u0440\u0435\u0439\u0434\u044b, \u043e\u0442\u0442\u043e\u043a\u0438 \u0438\u043b\u0438 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0426\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043d\u0430 \u0442\u043e\u043c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043b\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u043f\u043b\u0430\u0442\u0438\u0442\u044c \u0432\u0430\u043c \u0434\u0435\u043d\u044c\u0433\u0438: \u043f\u043e\u0436\u0438\u0437\u043d\u0435\u043d\u043d\u0430\u044f \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0441\u0443\u043c\u043c\u0430 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0430\u0441\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 <strong>\u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0435\u0436\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u043e\u0433\u043e \u0434\u043e\u0445\u043e\u0434\u0430 (Monthly Recurring Revenue, MRR)<\/strong>, \u0438 \u0435\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/92d\/c11\/7cd\/92dc117cd1313889d87575e99e574463.png\" width=\"1482\" height=\"1600\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/92d\/c11\/7cd\/92dc117cd1313889d87575e99e574463.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 MRR-\u0434\u0430\u0448\u0431\u043e\u0440\u0434 \u043f\u0443\u0442\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u044d\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043c\u043e\u0433\u0443\u0442 \u0441\u0442\u0430\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u0438 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c\u0438, \u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445. \u0412 \u043d\u0430\u0448\u0435\u043c \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c: <a href=\"https:\/\/docs.getdbt.com\/terms\/table\">\u0442\u0430\u0431\u043b\u0438\u0446\u0430<\/a>, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u043a \u0430\u043d\u0430\u043b\u0438\u0437\u0443. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u043d\u0430\u0448\u0435\u043c \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u044b \u2014 \u0432\u043e\u0442 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 \u043e\u0431\u0449\u0435\u0433\u043e MRR \u0437\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u0435\u0441\u044f\u0446:<\/p>\n<pre><code>select   date_month,   sum(is_active::integer) as customers,   sum(mrr) as mrr, from analytics.fct_mrr group by 1<\/code><\/pre>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0434\u0430\u0435\u0442 \u0440\u044f\u0434 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432:<\/p>\n<ul>\n<li>\n<p><strong>\u0412\u0430\u0448\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430 \u043a\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0430:<\/strong> \u041a\u0430\u0436\u0434\u044b\u0439 \u0431\u0438\u0437\u043d\u0435\u0441 \u0443\u043d\u0438\u043a\u0430\u043b\u0435\u043d. \u0422\u043e, \u043a\u0430\u043a \u0432 \u0432\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u043e\u0442\u0442\u043e\u043a, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438. \u041f\u043e\u0441\u0442\u0440\u043e\u0438\u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0443\u044e \u044d\u0442\u0443 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443, \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 \u0432\u0430\u0448\u0435\u0439 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0412\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435<\/strong>: \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0432\u0430\u0448\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043e\u043a \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b. \u0412\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0438\u0445 \u043f\u043e\u0434\u0447\u0438\u0441\u0442\u0438\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f NULL. \u0418\u043b\u0438 \u0432\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c <a href=\"https:\/\/docs.getdbt.com\/terms\/grain\">\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e<\/a> (grain) \u0442\u0430\u0431\u043b\u0438\u0446, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u043d\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443 \u0441 \u0434\u0430\u0442\u0430\u043c\u0438 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u0432\u0438\u0434\u0435 \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u0435\u0441\u044f\u0446. \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0432 \u044d\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u0430\u043c \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0445 \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u0432 \u0438\u043b\u0438 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 BI-\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0445.<\/p>\n<\/li>\n<li>\n<p><strong>\u0412\u0430\u0448\u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u044b<\/strong>: \u0421\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 dbt, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0434\u0435\u043b\u0430\u0435\u0442\u0435 \u043e \u0441\u0432\u043e\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432\u0430\u0448\u0430 \u0431\u044d\u043a\u0435\u043d\u0434-\u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043b\u0438\u0435\u043d\u0442 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0434\u0432\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e (<a href=\"https:\/\/github.com\/dbt-labs\/mrr-playbook\/blob\/master\/models\/schema.yml#L6\">\u0432\u043e\u0442<\/a> \u043f\u0440\u0438\u043c\u0435\u0440).<\/p>\n<\/li>\n<li>\n<p><strong>\u0411\u0438\u0437\u043d\u0435\u0441-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435:<\/strong> \u0415\u0441\u043b\u0438 \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u044f\u0446\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u0442\u043e\u043a\u043e\u0432 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0448\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e, \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0437\u0430\u0439\u0442\u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 SQL, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, <em>\u043a\u0430\u043a\u0438\u0435<\/em> \u0438\u043c\u0435\u043d\u043d\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u0443\u0448\u043b\u0438, \u043d\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u044f \u0441\u0435\u0431\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445 MRR<\/h3>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430 \u044d\u0442\u043e\u043c \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0432 \u043c\u0435\u0441\u044f\u0446 (\u0447\u0430\u0441\u0442\u043e \u044d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 &#171;grain&#187; \u043c\u043e\u0434\u0435\u043b\u0438). \u041a\u0430\u0436\u0434\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0434\u043e\u0445\u043e\u0434 \u0437\u0430 \u043c\u0435\u0441\u044f\u0446 (MRR), \u0430 \u0442\u0430\u043a\u0436\u0435 <em>\u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u0434\u043e\u0445\u043e\u0434 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043f\u0440\u043e\u0448\u043b\u044b\u043c \u043c\u0435\u0441\u044f\u0446\u0435\u043c.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th data-colwidth=\"236\" width=\"236\">\n<p>date_month<\/p>\n<\/th>\n<th data-colwidth=\"118\" width=\"118\">\n<p>customer_id<\/p>\n<\/th>\n<th data-colwidth=\"50\" width=\"50\">\n<p>mrr<\/p>\n<\/th>\n<th data-colwidth=\"131\" width=\"131\">\n<p>mrr_change<\/p>\n<\/th>\n<th>\n<p>change_category<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2018-11-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">50<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">50<\/p>\n<\/td>\n<td>\n<p align=\"left\">new<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2018-12-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">50<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u00a0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2019-01-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">50<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u00a0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2019-02-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">-50<\/p>\n<\/td>\n<td>\n<p align=\"left\">churn<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2019-03-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u00a0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2019-04-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">50<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">50<\/p>\n<\/td>\n<td>\n<p align=\"left\">reactivation<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2019-05-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">50<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u00a0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2019-06-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">75<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">25<\/p>\n<\/td>\n<td>\n<p align=\"left\">upgrade<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2019-07-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">75<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u00a0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2019-08-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">-75<\/p>\n<\/td>\n<td>\n<p align=\"left\">churn<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">\u2026<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">\u2026<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">\u2026<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">\u2026<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2026<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439:<\/p>\n<ul>\n<li>\n<p><strong>\u043d\u043e\u0432\u044b\u0439:<\/strong> \u043a\u043b\u0438\u0435\u043d\u0442 &#8212; \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438\u0444;<\/p>\n<\/li>\n<li>\n<p><strong>\u043e\u0442\u0442\u043e\u043a:<\/strong> \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u043c\u0435\u0441\u044f\u0446\u0435 \u043a\u043b\u0438\u0435\u043d\u0442 \u043e\u043f\u043b\u0430\u0442\u0438\u043b \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443, \u0430 \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u044f\u0446\u0435 \u043d\u0435\u0442. \u041a\u043b\u0438\u0435\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0438\u0434\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437;<\/p>\n<\/li>\n<li>\n<p><strong>\u0430\u043f\u0433\u0440\u0435\u0439\u0434:<\/strong> \u043a\u043b\u0438\u0435\u043d\u0442 \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u043b \u0432 \u043e\u0431\u044a\u0435\u043c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043b\u0430\u0442\u0438\u0442 \u0432\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0435\u043d\u0435\u0433 \u0432 \u043c\u0435\u0441\u044f\u0446;<\/p>\n<\/li>\n<li>\n<p><strong>\u0434\u0430\u0443\u043d\u0433\u0440\u0435\u0439\u0434:<\/strong> \u043a\u043b\u0438\u0435\u043d\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043b\u0430\u0442\u0438\u0442 \u0432\u0430\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u0435\u043d\u0435\u0433 \u0432 \u043c\u0435\u0441\u044f\u0446;<\/p>\n<\/li>\n<li>\n<p><strong>\u0440\u0435\u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u044f:<\/strong> \u043a\u043b\u0438\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u043d\u0435\u0435 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u043b\u0441\u044f, \u0432\u043e\u0437\u043e\u0431\u043d\u043e\u0432\u0438\u043b \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u0440\u0430\u0437\u0443 \u0433\u043e\u0442\u043e\u0432\u044b \u043e\u043a\u0443\u043d\u0443\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 dbt, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430\u0448 \u043e\u0431\u0440\u0430\u0437\u0435\u0446 MRR-\u043c\u043e\u0434\u0435\u043b\u0438 <a href=\"https:\/\/www.getdbt.com\/mrr-playbook\/#!\/overviewhttps:\/\/www.getdbt.com\/mrr-playbook\/#!\/overview\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0418\u043b\u0438 \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0434\u0430\u043b\u044c\u0448\u0435, \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u043b\u0435\u043d\u0438\u044f.<\/p>\n<h3>\u041a\u0430\u043a \u0441\u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0434\u043e\u0445\u043e\u0434\u0430\u043c \u043e\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438<\/h3>\n<h4>\u0428\u0430\u0433 1: \u0421\u043e\u0431\u0435\u0440\u0438\u0442\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0432 \u0432\u0430\u0448\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435. \u0414\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u0430\u0448\u0435\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 &#8212; \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445:<\/p>\n<ul>\n<li>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u0432 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u0441 \u0434\u0430\u0442\u0430\u043c\u0438 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0435\u0436\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u044b\u0445 \u0438\u043d\u0432\u043e\u0439\u0441\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0443\u043c\u043c\u0430 \u0441\u0447\u0435\u0442\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0430\u043f\u0433\u0440\u0435\u0439\u0434\u044b, \u0434\u0430\u0443\u043d\u0433\u0440\u0435\u0439\u0434\u044b \u0438 \u0430\u043d\u043d\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0443\u0447\u0435\u0431\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u043e\u0431\u0438\u044f \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u0432 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th data-colwidth=\"146\" width=\"146\">\n<p>subscription_id<\/p>\n<\/th>\n<th data-colwidth=\"123\" width=\"123\">\n<p>customer_id<\/p>\n<\/th>\n<th data-colwidth=\"124\" width=\"124\">\n<p>start_date<\/p>\n<\/th>\n<th data-colwidth=\"136\" width=\"136\">\n<p>end_date<\/p>\n<\/th>\n<th>\n<p>monthly_amount<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td data-colwidth=\"146\" width=\"146\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"123\" width=\"123\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"124\" width=\"124\">\n<p align=\"left\">2018-11-01<\/p>\n<\/td>\n<td data-colwidth=\"136\" width=\"136\">\n<p align=\"left\">2019-02-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">50<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"146\" width=\"146\">\n<p align=\"left\">2<\/p>\n<\/td>\n<td data-colwidth=\"123\" width=\"123\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"124\" width=\"124\">\n<p align=\"left\">2019-04-01<\/p>\n<\/td>\n<td data-colwidth=\"136\" width=\"136\">\n<p align=\"left\">2019-06-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">50<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"146\" width=\"146\">\n<p align=\"left\">3<\/p>\n<\/td>\n<td data-colwidth=\"123\" width=\"123\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"124\" width=\"124\">\n<p align=\"left\">2019-06-01<\/p>\n<\/td>\n<td data-colwidth=\"136\" width=\"136\">\n<p align=\"left\">2019-08-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">75<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0438\u043d\u0430\u0447\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 dbt, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u044d\u0442\u0443 \u0444\u043e\u0440\u043c\u0443.<\/p>\n<p>\u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u043a\u0436\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0447\u0438\u0441\u0442\u044b\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u043e\u0439.<\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u0442\u0430 \u0441\u0442\u0430\u0440\u0442\u0430 \u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u043d\u0430\u0447\u0430\u043b\u043e \u043c\u0435\u0441\u044f\u0446\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u044b \u0434\u0430\u0436\u0435 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u043b\u0438 \u0432\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 <a href=\"https:\/\/github.com\/dbt-labs\/mrr-playbook\/blob\/master\/models\/schema.yml#L4\">dbt-\u0442\u0435\u0441\u0442\u044b<\/a>!<\/p>\n<h4>\u0428\u0430\u0433 2: \u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043f\u043e \u0434\u0430\u0442\u0430\u043c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043c\u0435\u0441\u044f\u0446<\/h4>\n<p><em>\u0422\u0440\u0435\u0431\u0443\u0435\u043c\u0430\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0430 SQL: <\/em><a href=\"https:\/\/discourse.getdbt.com\/t\/finding-active-days-for-a-subscription-user-account-date-spining\/265\"><em>\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u0442 (date spining)<\/em><\/a><em> | \u0422\u0440\u0435\u0431\u0443\u0435\u043c\u0430\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0430 dbt: <\/em><a href=\"https:\/\/docs.getdbt.com\/docs\/package-management\"><em>\u043f\u0430\u043a\u0435\u0442\u044b<\/em><\/a><\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0435\u0436\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0442\u0430\u043a \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u043e\u0434\u043d\u0443 \u0437\u0430\u043f\u0438\u0441\u044c \u043d\u0430 \u043c\u0435\u0441\u044f\u0446, \u0430 \u043d\u0435 \u043e\u0434\u043d\u0443 \u0437\u0430\u043f\u0438\u0441\u044c \u043d\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>date_month<\/p>\n<\/th>\n<th>\n<p>customer_id<\/p>\n<\/th>\n<th>\n<p>monthly_amount<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">2018-11-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">50<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">2018-12-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">50<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">2019-01-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">50<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">2019-04-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">50<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">2019-05-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">50<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">2019-06-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">75<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">2019-07-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">75<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u2026<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2026<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2026<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0437\u0430 \u0441\u0447\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 &#171;\u043c\u0435\u0441\u044f\u0446\u0435\u0432&#187;:<\/p>\n<pre><code>select   months.date_month,   subscriptions.customer_id,   subscriptions.subscription_id,   susbcriptions.monthly_revenue    from subscriptions    inner join months   -- all months after start date   on  months.date_month >= customers.date_month_start   -- and before end date   and months.date_month &lt;= customers.date_month_end<\/code><\/pre>\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0430\u043a\u0440\u043e\u0441 <a href=\"https:\/\/github.com\/dbt-labs\/dbt-utils#date_spine-source\">date_spine<\/a> \u0438\u0437 <a href=\"https:\/\/docs.getdbt.com\/docs\/package-management\">\u043f\u0430\u043a\u0435\u0442\u0430<\/a> dbt-utils \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u0441\u0435\u0445 \u043c\u0435\u0441\u044f\u0446\u0435\u0432.<\/p>\n<p>\u041d\u043e \u043f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435, \u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043d\u0435 \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u0441 \u0444\u0435\u0432\u0440\u0430\u043b\u044f (2019-02-01) \u043f\u043e \u0430\u043f\u0440\u0435\u043b\u044c (2019-04-01), \u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043a\u0430\u043a &#171;\u043e\u0442\u0442\u043e\u043a&#187; \u0438 &#171;\u0440\u0435\u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u044e&#187;!<\/p>\n<p>\u0414\u043b\u044f MRR-\u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0432\u0430\u0436\u043d\u043e &#171;\u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c&#187; \u0432\u0441\u0435 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0441\u044f\u0446\u044b, \u043a\u043e\u0433\u0434\u0430 \u043a\u043b\u0438\u0435\u043d\u0442 \u043d\u0435 \u0431\u044b\u043b \u0430\u043a\u0442\u0438\u0432\u0435\u043d. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u0442\u044b \u0434\u043b\u044f \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438, \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 SQL, \u0447\u0442\u043e\u0431\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0442\u0438 \u0432\u0441\u0435 \u043c\u0435\u0441\u044f\u0446\u044b \u043c\u0435\u0436\u0434\u0443 \u043f\u0435\u0440\u0432\u043e\u0439 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0434\u0430\u0442.<\/p>\n<pre><code>with customers as (    select     customer_id,     date_trunc('month', min(start_date)) as date_month_start,     date_trunc('month', max(end_date)) as date_month_end    from subscription_periods    group by 1  ),  customer_months as (   select     customers.customer_id,     months.date_month    from customers      inner join months     -- all months after start date     on  months.date_month >= customers.date_month_start     -- and before end date     and months.date_month &lt;  customers.date_month_end    )    -- join the customer_months spine to MRR base model joined as (    select     customer_months.date_month,     customer_months.customer_id,     coalesce(subscription_periods.monthly_amount, 0) as mrr    from customer_months    left join subscription_periods     on customer_months.customer_id = subscription_periods.customer_id     -- month is after a subscription start date     and customer_months.date_month >= subscription_periods.start_date     -- month is before a subscription end date     and customer_months.date_month &lt; subscription_periods.end_date    ) ...<\/code><\/pre>\n<h4>\u0428\u0430\u0433 3: \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043c\u0435\u0441\u044f\u0446\u044b \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430<\/h4>\n<p><em>\u0422\u0440\u0435\u0431\u0443\u0435\u043c\u0430\u044f SQL-\u0442\u0435\u0445\u043d\u0438\u043a\u0430: \u041e\u043a\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/em><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u044f \u0432\u0441\u0435\u043c\u0438 \u043c\u0435\u0441\u044f\u0446\u0430\u043c\u0438 \u043f\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0443, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u043c \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u043a\u0430\u043a\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u043c \u0438\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u043c\u0435\u0441\u044f\u0446\u0435\u043c \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430.<\/p>\n<pre><code>... final as (   select     date_month,     customer_id,      mrr,      mrr > 0 as is_active,      -- calculate first and last months     min(case when is_active then date_month end) over (       partition by account_id     ) as first_active_month,      max(case when is_active then date_month end) over (       partition by account_id     ) as last_active_month,      -- calculate if this record is the first or last month     first_active_month = date_month as is_first_month,     last_active_month = date_month as is_last_month      from joined  )  select * from final<\/code><\/pre>\n<h4>\u0428\u0430\u0433 4: \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043c\u0435\u0441\u044f\u0446 &#171;\u043e\u0442\u0442\u043e\u043a\u0430&#187;<\/h4>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0430\u0441\u044c \u0432 \u0438\u044e\u043b\u0435, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0432 \u0430\u0432\u0433\u0443\u0441\u0442\u0435 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u043c\u0435\u0442\u043a\u0443 \u043e\u0431 \u043e\u0442\u0442\u043e\u043a\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u043b\u044f \u0430\u0432\u0433\u0443\u0441\u0442\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0434\u0430\u0442! \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0435.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0430\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0441\u044f\u0446\u0430 \u043d\u0430 \u043e\u0434\u0438\u043d \u0432\u043f\u0435\u0440\u0435\u0434. \u0417\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0441\u044f\u0446 \u043d\u0435 \u0431\u044b\u043b \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c.<\/p>\n<pre><code>select   dateadd(month, 1, date_month)::date as date_month,   customer_id,   0::float as mrr,   false as is_active,   first_active_month,   last_active_month,   false as is_first_month,   false as is_last_month    from mrr    where is_last_month<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c, \u0434\u0430\u043b\u0435\u0435, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0432 \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432\u0441\u0435 \u043c\u0435\u0441\u044f\u0446\u044b \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430.<\/p>\n<pre><code>with unioned as (    select * from {{ ref('mrr_xf') }}      union all      select * from {{ ref('mrr_last_churn') }} ) ...<\/code><\/pre>\n<h4>\u0428\u0430\u0433 5: \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043e\u043a\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f MRR \u0437\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043c\u0435\u0441\u044f\u0446<\/h4>\n<p>\u041f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043f\u0440\u043e\u0448\u043b\u043e\u043c\u0443 \u043c\u0435\u0441\u044f\u0446\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 lag, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043b\u0438\u0435\u043d\u0442 \u0437\u0430\u043f\u043b\u0430\u0442\u0438\u043b \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u043c\u0435\u0441\u044f\u0446\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a\u0443\u0440\u0441\u0430 \u0434\u043e\u043b\u043b\u0430\u0440\u0430.<\/p>\n<pre><code>select   *,    coalesce(     lag(is_active) over (partition by customer_id order by date_month),     false   ) as previous_month_is_active,    coalesce(     lag(mrr) over (partition by customer_id order by date_month),     0   ) as previous_month_mrr,      mrr - previous_month_mrr as mrr_change    from unioned<\/code><\/pre>\n<h4>\u0428\u0430\u0433 6: \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f MRR<\/h4>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0434\u043b\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439! \u0418 \u043a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, SQL \u0432 \u0438\u0442\u043e\u0433\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438 \u043b\u0435\u0433\u043a\u0438\u043c.<\/p>\n<pre><code>... case   when is_first_month       then 'new'   when not(is_active) and previous_month_is_active       then 'churn'   when is_active and not(previous_month_is_active)       then 'reactivation'   when mrr_change > 0 then 'upgrade'   when mrr_change &lt; 0 then 'downgrade' end as change_category<\/code><\/pre>\n<h4>\u0428\u0430\u0433 7: \u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0442\u0435\u0441\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/h4>\n<p>\u041c\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b\u0438 \u044d\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0448\u0430\u0433\u0430, \u043e\u0434\u043d\u0430\u043a\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u043c, \u043f\u043e\u043a\u0430 \u0432\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0435 \u0441\u0432\u043e\u0438 \u043c\u043e\u0434\u0435\u043b\u0438. \u0412\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0434\u0435\u043b\u0430\u0435\u0442\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e \u0441\u0432\u043e\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0442\u0435\u0441\u0442, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043e\u043d\u043e \u0432\u0435\u0440\u043d\u043e (\u043a\u0430\u043a \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445). \u041d\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u043d\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0438 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043d\u0443\u043b\u0435\u0432\u044b\u043c\u0438.<\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438: \u0422\u0435\u0441\u0442\u044b \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0430\u0448\u0438\u0445 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0422\u0435\u0441\u0442\u044b \u043d\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u044b \u043d\u0435 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 SQL, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438: \u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0432\u0430\u0448 <a href=\"https:\/\/docs.getdbt.com\/terms\/primary-key\">\u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447<\/a>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u0435\u0441\u0442 <code>unique<\/code> \u0438 <code>not_null<\/code> (\u044d\u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u044f\u0432\u0438\u0442\u044c \u0444\u0430\u043d\u0430\u0443\u0442\u044b!). \u0412\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u0442\u0435\u0441\u0442\u044b <code>not_null<\/code> \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0432\u044b, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u0435 \u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f edge \u043a\u0435\u0439\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u0435\u0434\u0443\u0433\u0430\u0434\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441.<\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u0432\u0430\u0448\u0438 \u0441\u0442\u0435\u0439\u043a\u0445\u043e\u043b\u0434\u0435\u0440\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u043b\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446.<\/p>\n<h4>\u0428\u0430\u0433 8: \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0439\u0442\u0435!<\/h4>\n<p>\u0412\u0430\u0448\u0430 \u043f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u0439. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 MVP, \u0437\u0430\u043a\u043e\u043c\u043c\u0438\u0442\u0438\u0442\u0435 \u0435\u0433\u043e \u0432 \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 dbt \u0438 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0432\u0430\u0448\u0438 \u0441\u0442\u0435\u0439\u043a\u0445\u043e\u043b\u0434\u0435\u0440\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c.<\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0434\u0438\u0442\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e \u0441\u0442\u0435\u0439\u043a\u0445\u043e\u043b\u0434\u0435\u0440\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438 \u043f\u043e\u043d\u044f\u0442\u044c, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u0438 \u043e\u043d\u0438 \u0432\u0430\u0436\u043d\u044b \u0434\u043b\u044f \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u0448\u0431\u043e\u0440\u0434 \u0448\u0438\u0440\u043e\u043a\u043e\u0439 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0438. \u041d\u0435 \u0434\u043e\u0436\u0438\u0434\u0430\u0439\u0442\u0435\u0441\u044c, \u043f\u043e\u043a\u0430 \u0432\u0430\u0448\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u0442\u0430\u043d\u0435\u0442 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u0439, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0435\u044e.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430<\/h2>\n<p>\u0425\u043e\u0442\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043b\u043e\u0433\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0440\u0443\u0447\u043a\u0438 \u043e\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0431\u0438\u0437\u043d\u0435\u0441\u043e\u0432 \u0441 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0434\u043e\u0445\u043e\u0434\u043e\u043c, \u043d\u044e\u0430\u043d\u0441\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u044f\u0442\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u044b \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0435.<\/p>\n<ol>\n<li>\n<p>\u041a\u0430\u043a \u0432\u0430\u0448 \u0431\u0438\u0437\u043d\u0435\u0441 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u0446\u0438\u0444\u0440\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u0441 \u0444\u0438\u043d\u0430\u043d\u0441\u043e\u0432\u044b\u043c\u0438 \u043e\u0442\u0447\u0435\u0442\u0430\u043c\u0438?<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0438 \u0432\u0430\u0448 \u0431\u0438\u0437\u043d\u0435\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443? \u0414\u043e\u043b\u0436\u043d\u043e \u043b\u0438 \u044d\u0442\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043d\u0430\u0447\u0435, \u0447\u0435\u043c \u043e\u0442\u0442\u043e\u043a?<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a\u043e\u0432\u0430 \u0432\u0430\u0448\u0430 \u0431\u0430\u0437\u043e\u0432\u0430\u044f \u0435\u0434\u0438\u043d\u0438\u0446\u0430 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f (\u0442.\u0435. \u043a\u043b\u0438\u0435\u043d\u0442, \u0430\u043a\u043a\u0430\u0443\u043d\u0442, \u043f\u0440\u043e\u0434\u0443\u043a\u0442)?<\/p>\n<\/li>\n<li>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043b\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u0432 \u044d\u0442\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0443?<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u043f\u043e\u043b\u043d\u044b\u0435 \u043c\u0435\u0441\u044f\u0446\u044b?<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0435 \u043b\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043e\u043f\u043b\u0430\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0434\u0435\u043d\u044c, \u0438\u043b\u0438 \u043e\u043d\u0438 \u043e\u043f\u043b\u0430\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u0434\u043d\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430? \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0442\u043e \u043a\u0430\u043a\u043e\u0432\u043e \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u043b\u044f \u043c\u0435\u0441\u044f\u0446\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0445\u043e\u0434?<\/p>\n<\/li>\n<\/ol>\n<p>\u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c, \u043d\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043d\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c. \u041c\u043d\u043e\u0433\u0438\u0435 \u0438\u0437 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441\u043e\u0432 &#8212; \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e MRR-\u0434\u0430\u0448\u0431\u043e\u0440\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043c\u043e\u0433\u0430\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0432 \u043e\u0446\u0435\u043d\u043a\u0435 <em>\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/em> \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438, \u0430 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0444\u0438\u043d\u0430\u043d\u0441\u043e\u0432\u043e\u0439 \u0441\u0432\u0435\u0440\u043a\u0438. \u0425\u043e\u0442\u044f \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0432\u0435\u0440\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u0430\u043a \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u0446\u0435\u043b\u044c, \u043d\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u0447\u0435\u0440\u043d\u0443\u044e \u0434\u044b\u0440\u0443, \u043f\u044b\u0442\u0430\u044f\u0441\u044c \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u043a\u0443\u0434\u0430 \u0434\u0435\u043b\u0438\u0441\u044c $0,02.<\/p>\n<p>\u041c\u044b \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c \u0432\u0430\u043c \u043f\u043e\u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u0442\u0435\u0439\u043a\u0445\u043e\u043b\u0434\u0435\u0440\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u0442\u044c, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0438 \u043d\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c MRR-\u0434\u0430\u0448\u0431\u043e\u0440\u0434, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0448 \u0431\u0438\u0437\u043d\u0435\u0441 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043d\u0435\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0432 \u0446\u0438\u0444\u0440\u0430\u0445.<\/p>\n<h3>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043a\u043e\u0434<\/h3>\n<p>\u041c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 dbt \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0435\u0433\u043e \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438:<\/p>\n<ul>\n<li>\n<p>\u041e\u0437\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 dbt <a href=\"https:\/\/www.getdbt.com\/mrr-playbook\/#!\/overview\">\u0437\u0434\u0435\u0441\u044c<\/a><\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/github.com\/dbt-labs\/mrr-playbook\">\u0437\u0434\u0435\u0441\u044c<\/a><\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0441\u043e\u0441\u0442\u043e\u0438\u0442\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0435 \u0437\u0430\u043d\u044f\u0442\u0438\u0435 \u043f\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041d\u0430 \u0443\u0440\u043e\u043a\u0435 \u043e\u0431\u0441\u0443\u0434\u0438\u043c: <br \/>\u2014 \u041a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0443\u0434\u043e\u0440\u0430\u0436\u0430\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u0435\u043b\u0435\u0439 DWH;<br \/>\u2014 \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438;<br \/>\u2014 \u041a\u0430\u043a \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0442\u0430\u043a \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c).<\/p>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043d\u0430 \u0443\u0440\u043e\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 <a href=\"https:\/\/otus.pw\/cDuv\/\">\u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435.<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \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\/704240\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/704240\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u044f\u0432\u043b\u044f\u0435\u0442\u0435\u0441\u044c \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 SaaS-\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u044f\u0442\u0438\u0438 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043a\u043e\u043c\u043c\u0435\u0440\u0446\u0438\u0438 \u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438, \u0432\u0430\u0441 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0441\u044f\u0442 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u043a\u0430\u043a \u043e\u0442\u0442\u043e\u043a, \u0430\u043f\u0433\u0440\u0435\u0439\u0434\u044b \u0438 \u0434\u0430\u0443\u043d\u0433\u0440\u0435\u0439\u0434\u044b. \u0414\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0431\u0438\u0437\u043d\u0435\u0441\u0443 \u043f\u043e\u043d\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>\u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u0430\u0448\u0435\u0439 \u0430\u0431\u043e\u043d\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0431\u0430\u0437\u044b \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0434\u043b\u0435\u043d\u0438\u0439 (\u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u044b \u0430\u043c\u043e\u0440\u0442\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0435 \u0434\u043e\u0445\u043e\u0434\u044b \u043f\u043e \u043c\u0435\u0441\u044f\u0446\u0430\u043c).<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u043e\u0445\u043e\u0434\u043e\u0432: \u043d\u043e\u0432\u044b\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u044b, \u0430\u043f\u0433\u0440\u0435\u0439\u0434\u044b, \u0434\u0430\u0443\u043d\u0433\u0440\u0435\u0439\u0434\u044b, \u043e\u0442\u0442\u043e\u043a\u0438 \u0438\u043b\u0438 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0426\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043d\u0430 \u0442\u043e\u043c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043b\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u043f\u043b\u0430\u0442\u0438\u0442\u044c \u0432\u0430\u043c \u0434\u0435\u043d\u044c\u0433\u0438: \u043f\u043e\u0436\u0438\u0437\u043d\u0435\u043d\u043d\u0430\u044f \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0441\u0443\u043c\u043c\u0430 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0430\u0441\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 <strong>\u0430\u043d\u0430\u043b\u0438\u0437\u043e\u043c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0435\u0436\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u043e\u0433\u043e \u0434\u043e\u0445\u043e\u0434\u0430 (Monthly Recurring Revenue, MRR)<\/strong>, \u0438 \u0435\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 MRR-\u0434\u0430\u0448\u0431\u043e\u0440\u0434 \u043f\u0443\u0442\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u044d\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043c\u043e\u0433\u0443\u0442 \u0441\u0442\u0430\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u0438 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c\u0438, \u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445. \u0412 \u043d\u0430\u0448\u0435\u043c \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c: <a href=\"https:\/\/docs.getdbt.com\/terms\/table\">\u0442\u0430\u0431\u043b\u0438\u0446\u0430<\/a>, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u043a \u0430\u043d\u0430\u043b\u0438\u0437\u0443. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u043d\u0430\u0448\u0435\u043c \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u044b \u2014 \u0432\u043e\u0442 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 \u043e\u0431\u0449\u0435\u0433\u043e MRR \u0437\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u0435\u0441\u044f\u0446:<\/p>\n<pre><code>select   date_month,   sum(is_active::integer) as customers,   sum(mrr) as mrr, from analytics.fct_mrr group by 1<\/code><\/pre>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0434\u0430\u0435\u0442 \u0440\u044f\u0434 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432:<\/p>\n<ul>\n<li>\n<p><strong>\u0412\u0430\u0448\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430 \u043a\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0430:<\/strong> \u041a\u0430\u0436\u0434\u044b\u0439 \u0431\u0438\u0437\u043d\u0435\u0441 \u0443\u043d\u0438\u043a\u0430\u043b\u0435\u043d. \u0422\u043e, \u043a\u0430\u043a \u0432 \u0432\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u043e\u0442\u0442\u043e\u043a, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438. \u041f\u043e\u0441\u0442\u0440\u043e\u0438\u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0443\u044e \u044d\u0442\u0443 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443, \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 \u0432\u0430\u0448\u0435\u0439 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0412\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435<\/strong>: \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0432\u0430\u0448\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043e\u043a \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b. \u0412\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0438\u0445 \u043f\u043e\u0434\u0447\u0438\u0441\u0442\u0438\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f NULL. \u0418\u043b\u0438 \u0432\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c <a href=\"https:\/\/docs.getdbt.com\/terms\/grain\">\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e<\/a> (grain) \u0442\u0430\u0431\u043b\u0438\u0446, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u043d\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443 \u0441 \u0434\u0430\u0442\u0430\u043c\u0438 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u0432\u0438\u0434\u0435 \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u0435\u0441\u044f\u0446. \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0432 \u044d\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u0430\u043c \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0445 \u0430\u043d\u0430\u043b\u0438\u0437\u043e\u0432 \u0438\u043b\u0438 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 BI-\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0445.<\/p>\n<\/li>\n<li>\n<p><strong>\u0412\u0430\u0448\u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u044b<\/strong>: \u0421\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 dbt, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0434\u0435\u043b\u0430\u0435\u0442\u0435 \u043e \u0441\u0432\u043e\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432\u0430\u0448\u0430 \u0431\u044d\u043a\u0435\u043d\u0434-\u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043b\u0438\u0435\u043d\u0442 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0434\u0432\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e (<a href=\"https:\/\/github.com\/dbt-labs\/mrr-playbook\/blob\/master\/models\/schema.yml#L6\">\u0432\u043e\u0442<\/a> \u043f\u0440\u0438\u043c\u0435\u0440).<\/p>\n<\/li>\n<li>\n<p><strong>\u0411\u0438\u0437\u043d\u0435\u0441-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435:<\/strong> \u0415\u0441\u043b\u0438 \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u044f\u0446\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u0442\u043e\u043a\u043e\u0432 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0448\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e, \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0437\u0430\u0439\u0442\u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 SQL, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, <em>\u043a\u0430\u043a\u0438\u0435<\/em> \u0438\u043c\u0435\u043d\u043d\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u044b \u0443\u0448\u043b\u0438, \u043d\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u044f \u0441\u0435\u0431\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445 MRR<\/h3>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430 \u044d\u0442\u043e\u043c \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0432 \u043c\u0435\u0441\u044f\u0446 (\u0447\u0430\u0441\u0442\u043e \u044d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 &#171;grain&#187; \u043c\u043e\u0434\u0435\u043b\u0438). \u041a\u0430\u0436\u0434\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0434\u043e\u0445\u043e\u0434 \u0437\u0430 \u043c\u0435\u0441\u044f\u0446 (MRR), \u0430 \u0442\u0430\u043a\u0436\u0435 <em>\u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u0434\u043e\u0445\u043e\u0434 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043f\u0440\u043e\u0448\u043b\u044b\u043c \u043c\u0435\u0441\u044f\u0446\u0435\u043c.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th data-colwidth=\"236\" width=\"236\">\n<p>date_month<\/p>\n<\/th>\n<th data-colwidth=\"118\" width=\"118\">\n<p>customer_id<\/p>\n<\/th>\n<th data-colwidth=\"50\" width=\"50\">\n<p>mrr<\/p>\n<\/th>\n<th data-colwidth=\"131\" width=\"131\">\n<p>mrr_change<\/p>\n<\/th>\n<th>\n<p>change_category<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2018-11-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">50<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">50<\/p>\n<\/td>\n<td>\n<p align=\"left\">new<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2018-12-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">50<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u00a0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2019-01-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">50<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u00a0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2019-02-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">-50<\/p>\n<\/td>\n<td>\n<p align=\"left\">churn<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2019-03-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u00a0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2019-04-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">50<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">50<\/p>\n<\/td>\n<td>\n<p align=\"left\">reactivation<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2019-05-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">50<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u00a0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2019-06-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">75<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">25<\/p>\n<\/td>\n<td>\n<p align=\"left\">upgrade<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2019-07-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">75<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u00a0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">2019-08-01 00:00:00.000<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">0<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">-75<\/p>\n<\/td>\n<td>\n<p align=\"left\">churn<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"236\" width=\"236\">\n<p align=\"left\">\u2026<\/p>\n<\/td>\n<td data-colwidth=\"118\" width=\"118\">\n<p align=\"left\">\u2026<\/p>\n<\/td>\n<td data-colwidth=\"50\" width=\"50\">\n<p align=\"left\">\u2026<\/p>\n<\/td>\n<td data-colwidth=\"131\" width=\"131\">\n<p align=\"left\">\u2026<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2026<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439:<\/p>\n<ul>\n<li>\n<p><strong>\u043d\u043e\u0432\u044b\u0439:<\/strong> \u043a\u043b\u0438\u0435\u043d\u0442 &#8212; \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438\u0444;<\/p>\n<\/li>\n<li>\n<p><strong>\u043e\u0442\u0442\u043e\u043a:<\/strong> \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u043c\u0435\u0441\u044f\u0446\u0435 \u043a\u043b\u0438\u0435\u043d\u0442 \u043e\u043f\u043b\u0430\u0442\u0438\u043b \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443, \u0430 \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u044f\u0446\u0435 \u043d\u0435\u0442. \u041a\u043b\u0438\u0435\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0438\u0434\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437;<\/p>\n<\/li>\n<li>\n<p><strong>\u0430\u043f\u0433\u0440\u0435\u0439\u0434:<\/strong> \u043a\u043b\u0438\u0435\u043d\u0442 \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u043b \u0432 \u043e\u0431\u044a\u0435\u043c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043b\u0430\u0442\u0438\u0442 \u0432\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0435\u043d\u0435\u0433 \u0432 \u043c\u0435\u0441\u044f\u0446;<\/p>\n<\/li>\n<li>\n<p><strong>\u0434\u0430\u0443\u043d\u0433\u0440\u0435\u0439\u0434:<\/strong> \u043a\u043b\u0438\u0435\u043d\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043b\u0430\u0442\u0438\u0442 \u0432\u0430\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u0435\u043d\u0435\u0433 \u0432 \u043c\u0435\u0441\u044f\u0446;<\/p>\n<\/li>\n<li>\n<p><strong>\u0440\u0435\u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u044f:<\/strong> \u043a\u043b\u0438\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u043d\u0435\u0435 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u043b\u0441\u044f, \u0432\u043e\u0437\u043e\u0431\u043d\u043e\u0432\u0438\u043b \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u0440\u0430\u0437\u0443 \u0433\u043e\u0442\u043e\u0432\u044b \u043e\u043a\u0443\u043d\u0443\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 dbt, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430\u0448 \u043e\u0431\u0440\u0430\u0437\u0435\u0446 MRR-\u043c\u043e\u0434\u0435\u043b\u0438 <a href=\"https:\/\/www.getdbt.com\/mrr-playbook\/#!\/overviewhttps:\/\/www.getdbt.com\/mrr-playbook\/#!\/overview\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u0418\u043b\u0438 \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0434\u0430\u043b\u044c\u0448\u0435, \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u043b\u0435\u043d\u0438\u044f.<\/p>\n<h3>\u041a\u0430\u043a \u0441\u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0434\u043e\u0445\u043e\u0434\u0430\u043c \u043e\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438<\/h3>\n<h4>\u0428\u0430\u0433 1: \u0421\u043e\u0431\u0435\u0440\u0438\u0442\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0432 \u0432\u0430\u0448\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435. \u0414\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u0430\u0448\u0435\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 &#8212; \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445:<\/p>\n<ul>\n<li>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u0432 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u0441 \u0434\u0430\u0442\u0430\u043c\u0438 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0435\u0436\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u044b\u0445 \u0438\u043d\u0432\u043e\u0439\u0441\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0443\u043c\u043c\u0430 \u0441\u0447\u0435\u0442\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0430\u043f\u0433\u0440\u0435\u0439\u0434\u044b, \u0434\u0430\u0443\u043d\u0433\u0440\u0435\u0439\u0434\u044b \u0438 \u0430\u043d\u043d\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0443\u0447\u0435\u0431\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u043e\u0431\u0438\u044f \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043f\u0435\u0440\u0438\u043e\u0434\u043e\u0432 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th data-colwidth=\"146\" width=\"146\">\n<p>subscription_id<\/p>\n<\/th>\n<th data-colwidth=\"123\" width=\"123\">\n<p>customer_id<\/p>\n<\/th>\n<th data-colwidth=\"124\" width=\"124\">\n<p>start_date<\/p>\n<\/th>\n<th data-colwidth=\"136\" width=\"136\">\n<p>end_date<\/p>\n<\/th>\n<th>\n<p>monthly_amount<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td data-colwidth=\"146\" width=\"146\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"123\" width=\"123\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"124\" width=\"124\">\n<p align=\"left\">2018-11-01<\/p>\n<\/td>\n<td data-colwidth=\"136\" width=\"136\">\n<p align=\"left\">2019-02-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">50<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"146\" width=\"146\">\n<p align=\"left\">2<\/p>\n<\/td>\n<td data-colwidth=\"123\" width=\"123\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"124\" width=\"124\">\n<p align=\"left\">2019-04-01<\/p>\n<\/td>\n<td data-colwidth=\"136\" width=\"136\">\n<p align=\"left\">2019-06-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">50<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"146\" width=\"146\">\n<p align=\"left\">3<\/p>\n<\/td>\n<td data-colwidth=\"123\" width=\"123\">\n<p align=\"left\">1<\/p>\n<\/td>\n<td data-colwidth=\"124\" width=\"124\">\n<p align=\"left\">2019-06-01<\/p>\n<\/td>\n<td data-colwidth=\"136\" width=\"136\">\n<p align=\"left\">2019-08-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">75<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0438\u043d\u0430\u0447\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 dbt, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u044d\u0442\u0443 \u0444\u043e\u0440\u043c\u0443.<\/p>\n<p>\u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u043a\u0436\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0447\u0438\u0441\u0442\u044b\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u043e\u0439.<\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u0442\u0430 \u0441\u0442\u0430\u0440\u0442\u0430 \u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u043d\u0430\u0447\u0430\u043b\u043e \u043c\u0435\u0441\u044f\u0446\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u044b \u0434\u0430\u0436\u0435 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u043b\u0438 \u0432\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 <a href=\"https:\/\/github.com\/dbt-labs\/mrr-playbook\/blob\/master\/models\/schema.yml#L4\">dbt-\u0442\u0435\u0441\u0442\u044b<\/a>!<\/p>\n<h4>\u0428\u0430\u0433 2: \u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043f\u043e \u0434\u0430\u0442\u0430\u043c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043c\u0435\u0441\u044f\u0446<\/h4>\n<p><em>\u0422\u0440\u0435\u0431\u0443\u0435\u043c\u0430\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0430 SQL: <\/em><a href=\"https:\/\/discourse.getdbt.com\/t\/finding-active-days-for-a-subscription-user-account-date-spining\/265\"><em>\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u0442 (date spining)<\/em><\/a><em> | \u0422\u0440\u0435\u0431\u0443\u0435\u043c\u0430\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0430 dbt: <\/em><a href=\"https:\/\/docs.getdbt.com\/docs\/package-management\"><em>\u043f\u0430\u043a\u0435\u0442\u044b<\/em><\/a><\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0435\u0436\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0442\u0430\u043a \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u043e\u0434\u043d\u0443 \u0437\u0430\u043f\u0438\u0441\u044c \u043d\u0430 \u043c\u0435\u0441\u044f\u0446, \u0430 \u043d\u0435 \u043e\u0434\u043d\u0443 \u0437\u0430\u043f\u0438\u0441\u044c \u043d\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p>date_month<\/p>\n<\/th>\n<th>\n<p>customer_id<\/p>\n<\/th>\n<th>\n<p>monthly_amount<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">2018-11-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">50<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">2018-12-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">50<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">2019-01-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">50<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">2019-04-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">50<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">2019-05-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">50<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">2019-06-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">75<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">2019-07-01<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<td>\n<p align=\"left\">75<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u2026<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2026<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2026<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0437\u0430 \u0441\u0447\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 &#171;\u043c\u0435\u0441\u044f\u0446\u0435\u0432&#187;:<\/p>\n<pre><code>select   months.date_month,   subscriptions.customer_id,   subscriptions.subscription_id,   susbcriptions.monthly_revenue    from subscriptions    inner join months   -- all months after start date   on  months.date_month >= customers.date_month_start   -- and before end date   and months.date_month &lt;= customers.date_month_end<\/code><\/pre>\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0430\u043a\u0440\u043e\u0441 <a href=\"https:\/\/github.com\/dbt-labs\/dbt-utils#date_spine-source\">date_spine<\/a> \u0438\u0437 <a href=\"https:\/\/docs.getdbt.com\/docs\/package-management\">\u043f\u0430\u043a\u0435\u0442\u0430<\/a> dbt-utils \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u0441\u0435\u0445 \u043c\u0435\u0441\u044f\u0446\u0435\u0432.<\/p>\n<p>\u041d\u043e \u043f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435, \u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043d\u0435 \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u0441 \u0444\u0435\u0432\u0440\u0430\u043b\u044f (2019-02-01) \u043f\u043e \u0430\u043f\u0440\u0435\u043b\u044c (2019-04-01), \u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043a\u0430\u043a &#171;\u043e\u0442\u0442\u043e\u043a&#187; \u0438 &#171;\u0440\u0435\u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u044e&#187;!<\/p>\n<p>\u0414\u043b\u044f MRR-\u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0432\u0430\u0436\u043d\u043e &#171;\u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c&#187; \u0432\u0441\u0435 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0441\u044f\u0446\u044b, \u043a\u043e\u0433\u0434\u0430 \u043a\u043b\u0438\u0435\u043d\u0442 \u043d\u0435 \u0431\u044b\u043b \u0430\u043a\u0442\u0438\u0432\u0435\u043d. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u0442\u044b \u0434\u043b\u044f \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438, \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 SQL, \u0447\u0442\u043e\u0431\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0439\u0442\u0438 \u0432\u0441\u0435 \u043c\u0435\u0441\u044f\u0446\u044b \u043c\u0435\u0436\u0434\u0443 \u043f\u0435\u0440\u0432\u043e\u0439 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0434\u0430\u0442.<\/p>\n<pre><code>with customers as (    select     customer_id,     date_trunc('month', min(start_date)) as date_month_start,     date_trunc('month', max(end_date)) as date_month_end    from subscription_periods    group by 1  ),  customer_months as (   select     customers.customer_id,     months.date_month    from customers      inner join months     -- all months after start date     on  months.date_month >= customers.date_month_start     -- and before end date     and months.date_month &lt;  customers.date_month_end    )    -- join the customer_months spine to MRR base model joined as (    select     customer_months.date_month,     customer_months.customer_id,     coalesce(subscription_periods.monthly_amount, 0) as mrr    from customer_months    left join subscription_periods     on customer_months.customer_id = subscription_periods.customer_id     -- month is after a subscription start date     and customer_months.date_month >= subscription_periods.start_date     -- month is before a subscription end date     and customer_months.date_month &lt; subscription_periods.end_date    ) ...<\/code><\/pre>\n<h4>\u0428\u0430\u0433 3: \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043c\u0435\u0441\u044f\u0446\u044b \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430<\/h4>\n<p><em>\u0422\u0440\u0435\u0431\u0443\u0435\u043c\u0430\u044f SQL-\u0442\u0435\u0445\u043d\u0438\u043a\u0430: \u041e\u043a\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/em><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u044f \u0432\u0441\u0435\u043c\u0438 \u043c\u0435\u0441\u044f\u0446\u0430\u043c\u0438 \u043f\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0443, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u043c \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u043a\u0430\u043a\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u043c \u0438\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u043c\u0435\u0441\u044f\u0446\u0435\u043c \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430.<\/p>\n<pre><code>... final as (   select     date_month,     customer_id,      mrr,      mrr > 0 as is_active,      -- calculate first and last months     min(case when is_active then date_month end) over (       partition by account_id     ) as first_active_month,      max(case when is_active then date_month end) over (       partition by account_id     ) as last_active_month,      -- calculate if this record is the first or last month     first_active_month = date_month as is_first_month,     last_active_month = date_month as is_last_month      from joined  )  select * from final<\/code><\/pre>\n<h4>\u0428\u0430\u0433 4: \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043c\u0435\u0441\u044f\u0446 &#171;\u043e\u0442\u0442\u043e\u043a\u0430&#187;<\/h4>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0430\u0441\u044c \u0432 \u0438\u044e\u043b\u0435, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0432 \u0430\u0432\u0433\u0443\u0441\u0442\u0435 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u043c\u0435\u0442\u043a\u0443 \u043e\u0431 \u043e\u0442\u0442\u043e\u043a\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u043b\u044f \u0430\u0432\u0433\u0443\u0441\u0442\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0434\u0430\u0442! \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0435.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0430\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0441\u044f\u0446\u0430 \u043d\u0430 \u043e\u0434\u0438\u043d \u0432\u043f\u0435\u0440\u0435\u0434. \u0417\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0441\u044f\u0446 \u043d\u0435 \u0431\u044b\u043b \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c.<\/p>\n<pre><code>select   dateadd(month, 1, date_month)::date as date_month,   customer_id,   0::float as mrr,   false as is_active,   first_active_month,   last_active_month,   false as is_first_month,   false as is_last_month    from mrr    where is_last_month<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c, \u0434\u0430\u043b\u0435\u0435, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0432 \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432\u0441\u0435 \u043c\u0435\u0441\u044f\u0446\u044b \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430.<\/p>\n<pre><code>with unioned as (    select * from {{ ref('mrr_xf') }}      union all      select * from {{ ref('mrr_last_churn') }} ) ...<\/code><\/pre>\n<h4>\u0428\u0430\u0433 5: \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043e\u043a\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f MRR \u0437\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043c\u0435\u0441\u044f\u0446<\/h4>\n<p>\u041f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043f\u0440\u043e\u0448\u043b\u043e\u043c\u0443 \u043c\u0435\u0441\u044f\u0446\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-342326","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/342326","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=342326"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/342326\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=342326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=342326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=342326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}