mirror of
https://gitlab.com/cief-data/dbt_cloud.git
synced 2026-08-19 04:14:00 +00:00
55 lines
2.0 KiB
SQL
55 lines
2.0 KiB
SQL
-- IMPORTS
|
|
WITH groups AS (
|
|
SELECT * FROM {{ source('src_exchange_mysql', 'groups') }}
|
|
),
|
|
|
|
|
|
-- LOGIC
|
|
groups_rename AS (
|
|
|
|
SELECT
|
|
groups.id,
|
|
groups.reference AS marking_id,
|
|
groups.issuer AS issued_by,
|
|
groups.receiver AS received_by,
|
|
groups.amount AS base_amount,
|
|
groups.original_amount AS quote_amount,
|
|
groups.currency_id AS base_currency_id,
|
|
groups.original_currency_id AS quote_currency_id,
|
|
groups.currency_rate AS base_to_quote_currency_exchange_rate,
|
|
groups.tax AS base_tax,
|
|
groups.service_charge AS base_service_charge,
|
|
groups.status,
|
|
groups.created_at,
|
|
groups.updated_at,
|
|
current_timestamp() AS _dbt_ran_at
|
|
|
|
FROM groups
|
|
),
|
|
|
|
|
|
-- FINAL
|
|
final__base_exchange__groups AS (
|
|
|
|
SELECT
|
|
id,
|
|
marking_id,
|
|
issued_by,
|
|
received_by,
|
|
base_amount,
|
|
quote_amount,
|
|
base_currency_id,
|
|
quote_currency_id,
|
|
base_to_quote_currency_exchange_rate,
|
|
base_tax,
|
|
base_service_charge,
|
|
status,
|
|
created_at,
|
|
updated_at,
|
|
_dbt_ran_at
|
|
|
|
FROM groups_rename
|
|
|
|
)
|
|
|
|
SELECT * FROM final__base_exchange__groups |