Created
March 5, 2022 16:35
-
-
Save MikeRzhevsky/9495cdca29946629995bc6d7ba5bdbee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| модель dm | |
| {{ config( | |
| as_columnstore=false, | |
| post_hook=[" | |
| {{ create_clustered_index(columns = ['Период']) }} | |
| {{ create_nonclustered_index(columns = ['Покупатель']) }} | |
| "] | |
| ) | |
| }} | |
| with datesort as ( | |
| select Период, {{ BinaryToChar('Покупатель') }} as Покупатель, СуммаВыкупа, СуммаОтказов, ПроцентВыкупа, Статус, | |
| ЗаказаноCущественныхТоваров, СтатусКарты, СуммаВыкупаДляДР, | |
| row_number() over(partition by Покупатель order by Период desc) as RowNum | |
| from {{ source('1c' , 'РегистрСведений.СтатусыКартыPrivilege') }} --[1c]._InfoRg24231 -- РегистрСведений.СтатусыКартыPrivilege | |
| ) | |
| select Период, | |
| Покупатель, | |
| СуммаВыкупа, | |
| СуммаОтказов, | |
| ПроцентВыкупа, | |
| Статус, | |
| ЗаказаноCущественныхТоваров, | |
| СтатусКарты, | |
| СуммаВыкупаДляДР | |
| from datesort | |
| where RowNum = 1 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
select indi.customer_id--,
--indi.redeem_percentage,
--indi.redeem_amount,
--indi.cancelled_orders_amount,
--indi.ordered_basic_goods_qty
from clickhouse.cifra.ct_privilege_cards__calculated_indicators as indi
WHERE NOT EXISTS
(SELECT dbt_statuses."покупатель" --,
--dbt_statuses."процентвыкупа",
--dbt_statuses."суммавыкупа",
--dbt_statuses."суммаотказов",
--dbt_statuses."заказаноcущественныхтоваров"
from cifratest.dbt_stage."dm_stage_регистрсведений_статусыкартprivilege" as dbt_statuses
where indi.customer_id = dbt_statuses."покупатель"
and indi.redeem_percentage = dbt_statuses."процентвыкупа"
and indi.redeem_amount = dbt_statuses."суммавыкупа"
and indi.cancelled_orders_amount = dbt_statuses."суммаотказов"
and indi.ordered_basic_goods_qty = dbt_statuses."заказаноcущественныхтоваров"
)
limit 100
-- SQL Server did not return a response. The connection has been closed.