Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with syncs_per_table as
- (
- select schema_name || '.' || table_name as schema_table, monthly_rows_synced
- from
- (
- select schema_name, table_name, round(30.42/14*total_rows_synced) as monthly_rows_synced
- from
- (
- select
- "schema" as schema_name, "table" as table_name,
- sum(rows_updated_or_inserted) as total_rows_synced
- from products_products.fivetran_audit
- where done >= '2016-08-08' and done < '2016-08-22'
- group by schema_name, table_name
- )
- union
- (
- select
- "schema" as schema_name, "table" as table_name,
- sum(rows_updated_or_inserted) as total_rows_synced
- from like2buy_like2buy.fivetran_audit
- where done >= '2016-08-08' and done < '2016-08-22'
- group by schema_name, table_name
- )
- union
- (
- select
- "schema" as schema_name, "table" as table_name,
- sum(rows_updated_or_inserted) as total_rows_synced
- from reels_web.fivetran_audit
- where done >= '2016-08-08' and done < '2016-08-22'
- group by schema_name, table_name
- )
- union
- (
- select
- "schema" as schema_name, "table" as table_name,
- sum(rows_updated_or_inserted) as total_rows_synced
- from reveal_widgets.fivetran_audit
- where done >= '2016-08-08' and done < '2016-08-22'
- group by schema_name, table_name
- )
- union
- (
- select
- "schema" as schema_name, "table" as table_name,
- sum(rows_updated_or_inserted) as total_rows_synced
- from web_campaigns.fivetran_audit
- where done >= '2016-08-08' and done < '2016-08-22'
- group by schema_name, table_name
- )
- union
- (
- select
- "schema" as schema_name, "table" as table_name,
- sum(rows_updated_or_inserted) as total_rows_synced
- from web_permissions.fivetran_audit
- where done >= '2016-08-08' and done < '2016-08-22'
- group by schema_name, table_name
- )
- union
- (
- select
- "schema" as schema_name, "table" as table_name,
- sum(rows_updated_or_inserted) as total_rows_synced
- from web_web.fivetran_audit
- where done >= '2016-08-08' and done < '2016-08-22'
- group by schema_name, table_name
- )
- )
- )
- select schema_table, monthly_rows_synced, total_volume, 100.0*monthly_rows_synced/total_volume as pcnt_volume
- from
- (
- select *
- from syncs_per_table
- )
- inner join
- (
- select sum(monthly_rows_synced) as total_volume
- from syncs_per_table
- )
- on 1=1
- order by monthly_rows_synced desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement