Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT derived_table1.username,
- derived_table1.mongo_id,
- derived_table1.email,
- derived_table1.is_partner,
- derived_table1.max_followers,
- derived_table1.max_overlay,
- derived_table1.max_songrequest,
- derived_table1.max_store,
- derived_table1.max_tips,
- derived_table1.max_bot,
- derived_table1.max_features_adopted,
- derived_table1."monthly views",
- derived_table1."monthly minutes viewed"
- FROM
- (SELECT users.twitch_username AS username,
- users.mongo_id,
- users.twitch_email AS email,
- users.is_partner,
- users.max_followers,
- users.max_overlay,
- users.max_songrequest,
- users.max_store,
- users.max_tips,
- users.max_bot,
- users.max_features_adopted,
- COALESCE(views."monthly views", 0) AS "monthly views",
- COALESCE(views."monthly minutes viewed", (0)::BIGINT) AS "monthly minutes viewed"
- FROM (
- (SELECT final_report.userid,
- final_report.twitch_username,
- final_report.twitch_email,
- final_report.is_partner,
- final_report.max_followers,
- final_report.max_overlay,
- final_report.max_songrequest,
- final_report.max_store,
- final_report.max_tips,
- final_report.max_bot,
- final_report.max_features_adopted,
- final_report.last_was_id,
- final_report._metadata_doc_id,
- channels.username,
- channels.profile_headerimage,
- channels.profile_title,
- channels.profile_social_twitter,
- channels.profile_social_youtube,
- channels.profile_social_facebook,
- channels.profile_social_instagram,
- channels.profile_social_website,
- channels.verified,
- channels.accesstoken,
- channels.mongo_id,
- channels.provider,
- channels.broadcastertype,
- channels.ispartner,
- channels.avatar,
- channels.suspended,
- channels.updatedat,
- channels.displayname,
- channels.lastlogin,
- channels.apitoken,
- channels.email,
- channels.createdat,
- channels.integrations_gamewisp_username,
- channels.integrations_gamewisp_expiresat,
- channels.integrations_gamewisp_channelid,
- channels.integrations_gamewisp_refreshtoken,
- channels.integrations_gamewisp_accesstoken,
- channels.refreshtoken,
- channels._metadata__uuid,
- channels._metadata__timestamp,
- channels._metadata_timestamp,
- channels._metadata_ordinal,
- channels._metadata_deleted,
- channels.providerid,
- channels.profile_social_discord,
- channels.users,
- channels.alias,
- channels.ab,
- channels.nullchannel,
- channels.db_action_type,
- channels.provideremails,
- channels.profile_language,
- channels.lastuseofoldtoken,
- channels."owner",
- channels.country
- FROM (
- (SELECT report.userid,
- report.twitch_username,
- report.twitch_email,
- report.is_partner,
- report.max_followers,
- report.max_overlay,
- report.max_songrequest,
- report.max_store,
- report.max_tips,
- report.max_bot,
- report.max_features_adopted,
- report.last_was_id,
- last_was._metadata_doc_id
- FROM
- (SELECT se_weeklyactivestreamers_report.userid,
- "max"((se_weeklyactivestreamers_report.username)::text) AS twitch_username,
- "max"((se_weeklyactivestreamers_report.email)::text) AS twitch_email,
- ("max"((se_weeklyactivestreamers_report.partner)::INTEGER))::BOOLEAN AS is_partner,
- "max"(se_weeklyactivestreamers_report.followers) AS max_followers,
- ("max"((se_weeklyactivestreamers_report."overlay")::INTEGER))::BOOLEAN AS max_overlay,
- ("max"((se_weeklyactivestreamers_report.songrequest)::INTEGER))::BOOLEAN AS max_songrequest,
- ("max"((se_weeklyactivestreamers_report.store)::INTEGER))::BOOLEAN AS max_store,
- ("max"((se_weeklyactivestreamers_report.tips)::INTEGER))::BOOLEAN AS max_tips,
- ("max"((se_weeklyactivestreamers_report.bot)::INTEGER))::BOOLEAN AS max_bot,
- ((((("max"((se_weeklyactivestreamers_report."overlay")::INTEGER) + "max"((se_weeklyactivestreamers_report."overlay")::INTEGER)) + "max"((se_weeklyactivestreamers_report.songrequest)::INTEGER)) + "max"((se_weeklyactivestreamers_report.store)::INTEGER)) + "max"((se_weeklyactivestreamers_report.tips)::INTEGER)) + "max"((se_weeklyactivestreamers_report.bot)::INTEGER)) AS max_features_adopted,
- "max"((se_weeklyactivestreamers_report.original_doc_id)::text) AS last_was_id
- FROM se_weeklyactivestreamers_report
- GROUP BY se_weeklyactivestreamers_report.userid) report,
- (SELECT se_weeklyactivestreamers._metadata_doc_id
- FROM se_weeklyactivestreamers
- ORDER BY se_weeklyactivestreamers.createdat DESC
- LIMIT 1) last_was
- WHERE (report.last_was_id = (last_was._metadata_doc_id)::text)) final_report
- JOIN se_channels channels ON (((final_report.userid)::text = (channels.mongo_id)::text)))) users
- LEFT JOIN
- (SELECT total.channel_mongo_id,
- (total.max_viewers - total.min_viewers) AS "monthly views",
- total."monthly minutes viewed"
- FROM
- (SELECT se_streams.channel_mongo_id,
- MIN(se_streams.total_viewers) AS min_viewers,
- "max"(se_streams.total_viewers) AS max_viewers,
- SUM(se_streams.minutes_viewed) AS "monthly minutes viewed"
- FROM se_streams
- WHERE ((se_streams."start" > (('now'::text)::DATE - '30 days'::INTERVAL))
- AND (se_streams.total_viewers > 0))
- GROUP BY se_streams.channel_mongo_id) total
- WHERE (total.min_viewers < total.max_viewers)) views ON (((users.mongo_id)::text = (views.channel_mongo_id)::text)))) derived_table1
- ORDER BY derived_table1.max_followers DESC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement