%3
(target) snapshot_ad_group_history_data
(target) snapshot_ad_group_history_data
ad_group_id
campaign_id
default_bid
ad_group_name
serving_status
state
(source) snapshot_facebook_ads_ad_set_history_data
(source) snapshot_facebook_ads_ad_set_history_data
ad_set_id
campaign_id
daily_budget
ad_set_name
status
(source) snapshot_facebook_ads_ad_set_history_data:f0->(target) snapshot_ad_group_history_data:f0
(source) snapshot_facebook_ads_ad_set_history_data:f1->(target) snapshot_ad_group_history_data:f1
(source) snapshot_facebook_ads_ad_set_history_data:f2->(target) snapshot_ad_group_history_data:f2
(source) snapshot_facebook_ads_ad_set_history_data:f3->(target) snapshot_ad_group_history_data:f3
(source) snapshot_facebook_ads_ad_set_history_data:f4->(target) snapshot_ad_group_history_data:f4
(source) snapshot_facebook_ads_ad_set_history_data:f4->(target) snapshot_ad_group_history_data:f5
(target) stg_ad_group_history_data
(target) stg_ad_group_history_data
ad_group_id
ad_group_name
ad_group_state
campaign_id
creation_date
last_updated_date
serving_status
(source) snapshot_facebook_ads_ad_set_history_data:f4->(target) stg_ad_group_history_data:f2
(source) snapshot_facebook_ads_ad_set_history_data:f4->(target) stg_ad_group_history_data:f6
(target) snapshot_campaign_history_data
(target) snapshot_campaign_history_data
campaign_name
campaign_state
end_date
serving_status
start_date
(source) snapshot_facebook_ads_campaign_history_data
(source) snapshot_facebook_ads_campaign_history_data
campaign_name
campaign_status
end_timestamp
start_timestamp
daily_budget_cents
lifetime_budget_cents
(source) snapshot_facebook_ads_campaign_history_data:f0->(target) snapshot_campaign_history_data:f0
(source) snapshot_facebook_ads_campaign_history_data:f1->(target) snapshot_campaign_history_data:f1
(source) snapshot_facebook_ads_campaign_history_data:f2->(target) snapshot_campaign_history_data:f2
(source) snapshot_facebook_ads_campaign_history_data:f1->(target) snapshot_campaign_history_data:f3
(source) snapshot_facebook_ads_campaign_history_data:f3->(target) snapshot_campaign_history_data:f4
(target) stg_advertised_product_report_data
(target) stg_advertised_product_report_data
ad_spend
budget_type
clicks
daily_budget_amount
impressions
report_date
(source) snapshot_facebook_ads_campaign_history_data:f4->(target) stg_advertised_product_report_data:f1
(source) snapshot_facebook_ads_campaign_history_data:f4->(target) stg_advertised_product_report_data:f3
(target) stg_campaign_history_data
(target) stg_campaign_history_data
budget_amount
budget_type
campaign_id
campaign_name
campaign_state
creation_date
end_date
last_updated_date
serving_status
start_date
(source) snapshot_facebook_ads_campaign_history_data:f4->(target) stg_campaign_history_data:f0
(source) snapshot_facebook_ads_campaign_history_data:f5->(target) stg_campaign_history_data:f0
(source) snapshot_facebook_ads_campaign_history_data:f4->(target) stg_campaign_history_data:f1
(source) snapshot_facebook_ads_campaign_history_data:f5->(target) stg_campaign_history_data:f1
(source) snapshot_facebook_ads_campaign_history_data:f1->(target) stg_campaign_history_data:f4
(source) snapshot_facebook_ads_campaign_history_data:f1->(target) stg_campaign_history_data:f8
(target) stg_campaign_level_report_data
(target) stg_campaign_level_report_data
budget_currency
clicks
cost
daily_budget_amount
impressions
report_date
(source) snapshot_facebook_ads_campaign_history_data:f4->(target) stg_campaign_level_report_data:f3
(target) snapshot_keyword_history_data
(target) snapshot_keyword_history_data
(target) snapshot_portfolio_history_data
(target) snapshot_portfolio_history_data
(target) snapshot_product_ad_history_data
(target) snapshot_product_ad_history_data
(source) stg_facebook_ads_ad_set_history_data
(source) stg_facebook_ads_ad_set_history_data
ad_set_id
ad_set_name
campaign_id
start_date
last_updated
(source) stg_facebook_ads_ad_set_history_data:f0->(target) stg_ad_group_history_data:f0
(source) stg_facebook_ads_ad_set_history_data:f1->(target) stg_ad_group_history_data:f1
(source) stg_facebook_ads_ad_set_history_data:f2->(target) stg_ad_group_history_data:f3
(source) stg_facebook_ads_ad_set_history_data:f3->(target) stg_ad_group_history_data:f4
(source) stg_facebook_ads_ad_set_history_data:f4->(target) stg_ad_group_history_data:f5
(target) stg_ad_group_level_report_data
(target) stg_ad_group_level_report_data
clicks
cost
impressions
performance_date
(source) stg_facebook_ads_basic_ad_data
(source) stg_facebook_ads_basic_ad_data
link_clicks
ad_spend
impressions
performance_date
(source) stg_facebook_ads_basic_ad_data:f0->(target) stg_ad_group_level_report_data:f0
(source) stg_facebook_ads_basic_ad_data:f1->(target) stg_ad_group_level_report_data:f1
(source) stg_facebook_ads_basic_ad_data:f2->(target) stg_ad_group_level_report_data:f2
(source) stg_facebook_ads_basic_ad_data:f3->(target) stg_ad_group_level_report_data:f3
(source) stg_facebook_ads_basic_ad_data:f1->(target) stg_advertised_product_report_data:f0
(source) stg_facebook_ads_basic_ad_data:f0->(target) stg_advertised_product_report_data:f2
(source) stg_facebook_ads_basic_ad_data:f2->(target) stg_advertised_product_report_data:f4
(source) stg_facebook_ads_basic_ad_data:f3->(target) stg_advertised_product_report_data:f5
(source) stg_facebook_ads_basic_ad_data:f0->(target) stg_campaign_level_report_data:f1
(source) stg_facebook_ads_basic_ad_data:f1->(target) stg_campaign_level_report_data:f2
(source) stg_facebook_ads_basic_ad_data:f2->(target) stg_campaign_level_report_data:f4
(source) stg_facebook_ads_basic_ad_data:f3->(target) stg_campaign_level_report_data:f5
(source) stg_facebook_ads_campaign_history_data
(source) stg_facebook_ads_campaign_history_data
campaign_id
campaign_name
creation_timestamp
end_timestamp
last_update_timestamp
start_timestamp
campaign_status
account_id
(source) stg_facebook_ads_campaign_history_data:f0->(target) stg_campaign_history_data:f2
(source) stg_facebook_ads_campaign_history_data:f1->(target) stg_campaign_history_data:f3
(source) stg_facebook_ads_campaign_history_data:f2->(target) stg_campaign_history_data:f5
(source) stg_facebook_ads_campaign_history_data:f3->(target) stg_campaign_history_data:f6
(source) stg_facebook_ads_campaign_history_data:f4->(target) stg_campaign_history_data:f7
(source) stg_facebook_ads_campaign_history_data:f5->(target) stg_campaign_history_data:f9
(target) stg_portfolio_history_data
(target) stg_portfolio_history_data
creation_date
currency_code
entry_id
last_updated_date
operational_status
portfolio_state
profile_id
(source) stg_facebook_ads_campaign_history_data:f2->(target) stg_portfolio_history_data:f0
(source) stg_facebook_ads_campaign_history_data:f0->(target) stg_portfolio_history_data:f2
(source) stg_facebook_ads_campaign_history_data:f4->(target) stg_portfolio_history_data:f3
(source) stg_facebook_ads_campaign_history_data:f6->(target) stg_portfolio_history_data:f4
(source) stg_facebook_ads_campaign_history_data:f6->(target) stg_portfolio_history_data:f5
(source) stg_facebook_ads_campaign_history_data:f7->(target) stg_portfolio_history_data:f6
(source) snapshot_facebook_ads_account_history_data
(source) snapshot_facebook_ads_account_history_data
account_currency
(source) snapshot_facebook_ads_account_history_data:f0->(target) stg_campaign_level_report_data:f0
(source) snapshot_facebook_ads_account_history_data:f0->(target) stg_portfolio_history_data:f1
(target) stg_keyword_history_data
(target) stg_keyword_history_data
(target) stg_product_ad_history_data
(target) stg_product_ad_history_data
(target) stg_profile_data
(target) stg_profile_data
account_id
country_code
currency_code
timezone
(source) stg_facebook_ads_account_history_data
(source) stg_facebook_ads_account_history_data
account_id
country_code
account_currency
account_timezone
(source) stg_facebook_ads_account_history_data:f0->(target) stg_profile_data:f0
(source) stg_facebook_ads_account_history_data:f1->(target) stg_profile_data:f1
(source) stg_facebook_ads_account_history_data:f2->(target) stg_profile_data:f2
(source) stg_facebook_ads_account_history_data:f3->(target) stg_profile_data:f3
(target) stg_targeting_keyword_report_data
(target) stg_targeting_keyword_report_data
%3
(target) snapshot_ad_group_history_data
(target) snapshot_ad_group_history_data
ad_group_id
campaign_id
default_bid
ad_group_name
serving_status
state
(source) snapshot_facebook_ads_ad_set_history_data
(source) snapshot_facebook_ads_ad_set_history_data
ad_set_id
campaign_id
daily_budget
ad_set_name
status
(source) snapshot_facebook_ads_ad_set_history_data:f0->(target) snapshot_ad_group_history_data:f0
(source) snapshot_facebook_ads_ad_set_history_data:f1->(target) snapshot_ad_group_history_data:f1
(source) snapshot_facebook_ads_ad_set_history_data:f2->(target) snapshot_ad_group_history_data:f2
(source) snapshot_facebook_ads_ad_set_history_data:f3->(target) snapshot_ad_group_history_data:f3
(source) snapshot_facebook_ads_ad_set_history_data:f4->(target) snapshot_ad_group_history_data:f4
(source) snapshot_facebook_ads_ad_set_history_data:f4->(target) snapshot_ad_group_history_data:f5
SELECT
ad_set_id AS ad_group_id ,
campaign_id ,
daily_budget AS default_bid ,
ad_set_name AS ad_group_name ,
status AS serving_status ,
status AS state
FROM
snapshot_facebook_ads_ad_set_history_data
⚠️ SQL query is just for reference based on schema. To ensure correctness, data access is required.
%3
(target) snapshot_campaign_history_data
(target) snapshot_campaign_history_data
campaign_name
campaign_state
end_date
serving_status
start_date
(source) snapshot_facebook_ads_campaign_history_data
(source) snapshot_facebook_ads_campaign_history_data
campaign_name
campaign_status
end_timestamp
start_timestamp
(source) snapshot_facebook_ads_campaign_history_data:f0->(target) snapshot_campaign_history_data:f0
(source) snapshot_facebook_ads_campaign_history_data:f1->(target) snapshot_campaign_history_data:f1
(source) snapshot_facebook_ads_campaign_history_data:f2->(target) snapshot_campaign_history_data:f2
(source) snapshot_facebook_ads_campaign_history_data:f1->(target) snapshot_campaign_history_data:f3
(source) snapshot_facebook_ads_campaign_history_data:f3->(target) snapshot_campaign_history_data:f4
SELECT
campaign_name AS campaign_name ,
CASE
WHEN campaign_status = 'ACTIVE' THEN 'enabled'
WHEN campaign_status = 'PAUSED' THEN 'paused'
WHEN campaign_status = 'DELETED' THEN NULL
END AS campaign_state ,
end_timestamp AS end_date ,
CASE
WHEN campaign_status = 'ACTIVE' THEN 'CAMPAIGN_STATUS_ENABLED'
WHEN campaign_status = 'PAUSED' THEN 'CAMPAIGN_PAUSED'
WHEN campaign_status = 'DELETED' THEN NULL
END AS serving_status ,
start_timestamp AS start_date
FROM
snapshot_facebook_ads_campaign_history_data
⚠️ SQL query is just for reference based on schema. To ensure correctness, data access is required.
%3
(target) snapshot_keyword_history_data
(target) snapshot_keyword_history_data
⚠️ SQL query is just for reference based on schema. To ensure correctness, data access is required.
%3
(target) snapshot_portfolio_history_data
(target) snapshot_portfolio_history_data
⚠️ SQL query is just for reference based on schema. To ensure correctness, data access is required.
%3
(target) snapshot_product_ad_history_data
(target) snapshot_product_ad_history_data
⚠️ SQL query is just for reference based on schema. To ensure correctness, data access is required.
%3
(target) stg_ad_group_history_data
(target) stg_ad_group_history_data
ad_group_id
ad_group_name
ad_group_state
campaign_id
creation_date
last_updated_date
serving_status
(source) stg_facebook_ads_ad_set_history_data
(source) stg_facebook_ads_ad_set_history_data
ad_set_id
ad_set_name
campaign_id
start_date
last_updated
(source) stg_facebook_ads_ad_set_history_data:f0->(target) stg_ad_group_history_data:f0
(source) stg_facebook_ads_ad_set_history_data:f1->(target) stg_ad_group_history_data:f1
(source) stg_facebook_ads_ad_set_history_data:f2->(target) stg_ad_group_history_data:f3
(source) stg_facebook_ads_ad_set_history_data:f3->(target) stg_ad_group_history_data:f4
(source) stg_facebook_ads_ad_set_history_data:f4->(target) stg_ad_group_history_data:f5
(source) snapshot_facebook_ads_ad_set_history_data
(source) snapshot_facebook_ads_ad_set_history_data
status
(source) snapshot_facebook_ads_ad_set_history_data:f0->(target) stg_ad_group_history_data:f2
(source) snapshot_facebook_ads_ad_set_history_data:f0->(target) stg_ad_group_history_data:f6
SELECT
stg . ad_set_id AS ad_group_id ,
stg . ad_set_name AS ad_group_name ,
CASE
WHEN snap . status = 'ACTIVE' THEN 'enabled'
WHEN snap . status = 'PAUSED' THEN 'paused'
WHEN snap . status = 'DELETED' THEN 'disabled'
ELSE NULL
END AS ad_group_state ,
stg . campaign_id ,
stg . start_date AS creation_date ,
stg . last_updated AS last_updated_date ,
CASE
WHEN snap . status = 'ACTIVE' THEN 'AD_STATUS_LIVE'
WHEN snap . status = 'PAUSED' THEN 'CAMPAIGN_PAUSED'
ELSE NULL
END AS serving_status
FROM
stg_facebook_ads_ad_set_history_data stg
LEFT JOIN
snapshot_facebook_ads_ad_set_history_data snap
ON stg . ad_set_id = snap . ad_set_id -- Assuming this is the correct join condition
WHERE
stg . ad_set_id IS NOT NULL -- Ensure we only get rows with valid ad_set_id
⚠️ SQL query is just for reference based on schema. To ensure correctness, data access is required.
%3
(target) stg_ad_group_level_report_data
(target) stg_ad_group_level_report_data
clicks
cost
impressions
performance_date
(source) stg_facebook_ads_basic_ad_data
(source) stg_facebook_ads_basic_ad_data
link_clicks
ad_spend
impressions
performance_date
(source) stg_facebook_ads_basic_ad_data:f0->(target) stg_ad_group_level_report_data:f0
(source) stg_facebook_ads_basic_ad_data:f1->(target) stg_ad_group_level_report_data:f1
(source) stg_facebook_ads_basic_ad_data:f2->(target) stg_ad_group_level_report_data:f2
(source) stg_facebook_ads_basic_ad_data:f3->(target) stg_ad_group_level_report_data:f3
SELECT
fb . link_clicks AS clicks ,
fb . ad_spend AS cost ,
fb . impressions ,
fb . performance_date
FROM
stg_facebook_ads_basic_ad_data fb
JOIN
snapshot_facebook_ads_ad_set_history_data ad_set
ON fb . adset_name = ad_set . ad_set_name
⚠️ SQL query is just for reference based on schema. To ensure correctness, data access is required.
%3
(target) stg_advertised_product_report_data
(target) stg_advertised_product_report_data
ad_spend
budget_type
clicks
daily_budget_amount
impressions
report_date
(source) stg_facebook_ads_basic_ad_data
(source) stg_facebook_ads_basic_ad_data
ad_spend
link_clicks
impressions
performance_date
(source) stg_facebook_ads_basic_ad_data:f0->(target) stg_advertised_product_report_data:f0
(source) stg_facebook_ads_basic_ad_data:f1->(target) stg_advertised_product_report_data:f2
(source) stg_facebook_ads_basic_ad_data:f2->(target) stg_advertised_product_report_data:f4
(source) stg_facebook_ads_basic_ad_data:f3->(target) stg_advertised_product_report_data:f5
(source) snapshot_facebook_ads_campaign_history_data
(source) snapshot_facebook_ads_campaign_history_data
daily_budget_cents
(source) snapshot_facebook_ads_campaign_history_data:f0->(target) stg_advertised_product_report_data:f1
(source) snapshot_facebook_ads_campaign_history_data:f0->(target) stg_advertised_product_report_data:f3
SELECT
b . ad_spend ,
CASE
WHEN c . daily_budget_cents IS NOT NULL THEN 'DAILY_BUDGET'
ELSE NULL
END AS budget_type ,
b . link_clicks AS clicks ,
c . daily_budget_cents / 100 AS daily_budget_amount ,
b . impressions ,
b . performance_date AS report_date
FROM
stg_facebook_ads_basic_ad_data b
JOIN
snapshot_facebook_ads_ad_history_data a ON b . ad_id = a . ad_id
JOIN
snapshot_facebook_ads_campaign_history_data c ON a . campaign_id = c . campaign_id
⚠️ SQL query is just for reference based on schema. To ensure correctness, data access is required.
%3
(target) stg_campaign_history_data
(target) stg_campaign_history_data
budget_amount
budget_type
campaign_id
campaign_name
campaign_state
creation_date
end_date
last_updated_date
serving_status
start_date
(source) snapshot_facebook_ads_campaign_history_data
(source) snapshot_facebook_ads_campaign_history_data
daily_budget_cents
lifetime_budget_cents
campaign_status
(source) snapshot_facebook_ads_campaign_history_data:f0->(target) stg_campaign_history_data:f0
(source) snapshot_facebook_ads_campaign_history_data:f1->(target) stg_campaign_history_data:f0
(source) snapshot_facebook_ads_campaign_history_data:f0->(target) stg_campaign_history_data:f1
(source) snapshot_facebook_ads_campaign_history_data:f1->(target) stg_campaign_history_data:f1
(source) snapshot_facebook_ads_campaign_history_data:f2->(target) stg_campaign_history_data:f4
(source) snapshot_facebook_ads_campaign_history_data:f2->(target) stg_campaign_history_data:f8
(source) stg_facebook_ads_campaign_history_data
(source) stg_facebook_ads_campaign_history_data
campaign_id
campaign_name
creation_timestamp
end_timestamp
last_update_timestamp
start_timestamp
(source) stg_facebook_ads_campaign_history_data:f0->(target) stg_campaign_history_data:f2
(source) stg_facebook_ads_campaign_history_data:f1->(target) stg_campaign_history_data:f3
(source) stg_facebook_ads_campaign_history_data:f2->(target) stg_campaign_history_data:f5
(source) stg_facebook_ads_campaign_history_data:f3->(target) stg_campaign_history_data:f6
(source) stg_facebook_ads_campaign_history_data:f4->(target) stg_campaign_history_data:f7
(source) stg_facebook_ads_campaign_history_data:f5->(target) stg_campaign_history_data:f9
SELECT
COALESCE ( s . daily_budget_cents , s . lifetime_budget_cents ) / 100 . 0 AS budget_amount ,
CASE WHEN s . daily_budget_cents IS NOT NULL THEN 'daily' ELSE NULL END AS budget_type ,
stg . campaign_id ,
stg . campaign_name ,
CASE
WHEN s . campaign_status = 'ACTIVE' THEN 'enabled'
WHEN s . campaign_status = 'PAUSED' THEN 'paused'
WHEN s . campaign_status = 'DELETED' THEN NULL
END AS campaign_state ,
stg . creation_timestamp AS creation_date ,
stg . end_timestamp AS end_date ,
stg . last_update_timestamp AS last_updated_date ,
CASE
WHEN s . campaign_status = 'ACTIVE' THEN 'CAMPAIGN_STATUS_ENABLED'
WHEN s . campaign_status = 'PAUSED' THEN 'CAMPAIGN_PAUSED'
WHEN s . campaign_status = 'DELETED' THEN NULL
END AS serving_status ,
stg . start_timestamp AS start_date
FROM
snapshot_facebook_ads_campaign_history_data s
FULL OUTER JOIN
stg_facebook_ads_campaign_history_data stg
ON
s . campaign_id = stg . campaign_id
⚠️ SQL query is just for reference based on schema. To ensure correctness, data access is required.
%3
(target) stg_campaign_level_report_data
(target) stg_campaign_level_report_data
budget_currency
clicks
cost
daily_budget_amount
impressions
report_date
(source) snapshot_facebook_ads_account_history_data
(source) snapshot_facebook_ads_account_history_data
account_currency
(source) snapshot_facebook_ads_account_history_data:f0->(target) stg_campaign_level_report_data:f0
(source) stg_facebook_ads_basic_ad_data
(source) stg_facebook_ads_basic_ad_data
link_clicks
ad_spend
impressions
performance_date
(source) stg_facebook_ads_basic_ad_data:f0->(target) stg_campaign_level_report_data:f1
(source) stg_facebook_ads_basic_ad_data:f1->(target) stg_campaign_level_report_data:f2
(source) stg_facebook_ads_basic_ad_data:f2->(target) stg_campaign_level_report_data:f4
(source) stg_facebook_ads_basic_ad_data:f3->(target) stg_campaign_level_report_data:f5
(source) snapshot_facebook_ads_campaign_history_data
(source) snapshot_facebook_ads_campaign_history_data
daily_budget_cents
(source) snapshot_facebook_ads_campaign_history_data:f0->(target) stg_campaign_level_report_data:f3
SELECT
saa . account_currency AS budget_currency ,
sfb . link_clicks AS clicks ,
sfb . ad_spend AS cost ,
sfc . daily_budget_cents / 100 AS daily_budget_amount ,
sfb . impressions ,
sfb . performance_date AS report_date
FROM
stg_facebook_ads_basic_ad_data sfb
JOIN
snapshot_facebook_ads_account_history_data saa ON sfb . account_id = saa . account_id
JOIN
snapshot_facebook_ads_campaign_history_data sfc ON sfb . campaign_id = sfc . campaign_id
WHERE
saa . is_latest = TRUE
AND sfc . is_latest = TRUE
⚠️ SQL query is just for reference based on schema. To ensure correctness, data access is required.
%3
(target) stg_keyword_history_data
(target) stg_keyword_history_data
⚠️ SQL query is just for reference based on schema. To ensure correctness, data access is required.
%3
(target) stg_portfolio_history_data
(target) stg_portfolio_history_data
creation_date
currency_code
entry_id
last_updated_date
operational_status
portfolio_state
profile_id
(source) stg_facebook_ads_campaign_history_data
(source) stg_facebook_ads_campaign_history_data
creation_timestamp
campaign_id
last_update_timestamp
campaign_status
account_id
(source) stg_facebook_ads_campaign_history_data:f0->(target) stg_portfolio_history_data:f0
(source) stg_facebook_ads_campaign_history_data:f1->(target) stg_portfolio_history_data:f2
(source) stg_facebook_ads_campaign_history_data:f2->(target) stg_portfolio_history_data:f3
(source) stg_facebook_ads_campaign_history_data:f3->(target) stg_portfolio_history_data:f4
(source) stg_facebook_ads_campaign_history_data:f3->(target) stg_portfolio_history_data:f5
(source) stg_facebook_ads_campaign_history_data:f4->(target) stg_portfolio_history_data:f6
(source) snapshot_facebook_ads_account_history_data
(source) snapshot_facebook_ads_account_history_data
account_currency
(source) snapshot_facebook_ads_account_history_data:f0->(target) stg_portfolio_history_data:f1
SELECT
c . creation_timestamp AS creation_date ,
a . account_currency AS currency_code ,
c . campaign_id AS entry_id ,
c . last_update_timestamp AS last_updated_date ,
CASE
WHEN c . campaign_status = 'ACTIVE' THEN 'PORTFOLIO_STATUS_ENABLED'
WHEN c . campaign_status = 'PAUSED' THEN 'PORTFOLIO_STATUS_PAUSED'
ELSE NULL
END AS operational_status ,
CASE
WHEN c . campaign_status = 'ACTIVE' THEN 'enabled'
WHEN c . campaign_status = 'PAUSED' THEN 'paused'
ELSE NULL
END AS portfolio_state ,
c . account_id AS profile_id
FROM
stg_facebook_ads_campaign_history_data c
JOIN
snapshot_facebook_ads_account_history_data a ON c . account_id = a . account_id
⚠️ SQL query is just for reference based on schema. To ensure correctness, data access is required.
%3
(target) stg_product_ad_history_data
(target) stg_product_ad_history_data
⚠️ SQL query is just for reference based on schema. To ensure correctness, data access is required.
%3
(target) stg_profile_data
(target) stg_profile_data
account_id
country_code
currency_code
timezone
(source) stg_facebook_ads_account_history_data
(source) stg_facebook_ads_account_history_data
account_id
country_code
account_currency
account_timezone
(source) stg_facebook_ads_account_history_data:f0->(target) stg_profile_data:f0
(source) stg_facebook_ads_account_history_data:f1->(target) stg_profile_data:f1
(source) stg_facebook_ads_account_history_data:f2->(target) stg_profile_data:f2
(source) stg_facebook_ads_account_history_data:f3->(target) stg_profile_data:f3
SELECT
account_id AS account_id ,
country_code AS country_code ,
CASE
WHEN account_currency = 'USD' THEN 'USD'
WHEN account_currency = 'GBP' THEN 'GBP'
WHEN account_currency = 'JPY' THEN 'JPY'
-- Add more currency mappings as needed
ELSE account_currency -- Default case if no mapping is specified
END AS currency_code ,
account_timezone AS timezone
FROM
stg_facebook_ads_account_history_data
⚠️ SQL query is just for reference based on schema. To ensure correctness, data access is required.
%3
(target) stg_targeting_keyword_report_data
(target) stg_targeting_keyword_report_data
⚠️ SQL query is just for reference based on schema. To ensure correctness, data access is required.