Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- order_id AS "id заявки",
- CAST (STATUS AS INT) AS "id статуса заявки",
- loan_number AS "Присвоенный заявке номер договора",
- client_id AS "id клиента",
- CONVERT(INT,
- FLOOR((creation_datetime - client_bithday)/ 365.25)) AS "Возраст клиента",
- (
- SELECT
- COUNT(*)
- FROM
- orders AS tt1
- WHERE
- tt1.ENABLED = 1
- AND tt1.CLIENTID = client_id
- AND tt1.id <order_id
- AND tt1.ORDERSTATUS>3) AS "Сколько уже было выдач клиенту",
- creation_office_id AS "id места создания заявки",
- creation_user_id AS "id создателя заявки",
- CONVERT(DATETIME, creation_datetime) AS "Дата и время создания заявки", -- дата
- creation_loan_sum AS "Запрошенный размер займа",
- CAST (creation_loan_days AS INT) AS "Запрошенный срок",
- CONVERT(DATETIME, decision_datetime) AS "Дата и время принятия решения", --дата
- decision_user_id AS "id пользователя, обработавшего заявку",
- loan_product AS "id продукта",
- decision_loan_sum AS "Одобренный размер займа",
- CONVERT(DATETIME, issued_datetime) AS "Дата и время выдачи", --дата
- issued_office_id AS "id места выдачи",
- issued_payment_agent_id AS "id платёжного агента",
- CONVERT(INT,
- FLOOR(issued_datetime) - FLOOR(decision_datetime)) AS "На какой день от одобрения выдан заём",
- CAST ((issued_datetime - decision_datetime)* 1440 AS INT) AS "Через сколько минут от одобрения выдан заём",
- issued_loan_sum AS "Размер займа",
- issued_loan_days AS "Выдано на срок",
- CONVERT(DATETIME, current_expected_date) AS "Ожидаемая дата закрытия", --дата
- CONVERT(DATETIME, FLOOR(close_datetime)) AS "Дата закрытия договора", --дата
- CONVERT(bit,
- close_recalculated) AS "Был ли перерасчёт при закрытии",
- partner_id
- FROM
- powerbi_orders
- WHERE
- creation_loan_sum <> 66666 AND
- creation_datetime >= DATEADD(DAY, -7, GETDATE())
- AND creation_datetime < GETDATE()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement