解读 sql select t_main.company_name, column_entity3_tag4985 from ( select cast(company_name as string) as company_name from dw_cg_profile.app_cust_company_base_info_profile_df where (date = '${date}') ) t_main join ( select company_name, column_entity3_tag4985 from ( select company_name, account_id, column_entity3_tag4985, row_number() over( partition by company_name order by row_num ) as rank_num from ( select t1.account_id as account_id, company_name, tag4600 as column_entity3_tag4985, case when tag4600 = 10 then 1 else 2 end as row_num from ( select cast(account_id as bigint) as account_id, l7d_video_play_cnt_5s as tag4600 from dw_cg_profile.app_xingyao_account_profile_for_push_df where (date = '${date}') ) t1 join ( select cast(account_id as bigint) as account_id, cast(company_name as string) as company_name from dw_cg_profile.dwd_xingyao_account_company_name_ref_df
时间: 2023-11-24 19:07:08 浏览: 62
该SQL语句通过两个子查询和一个JOIN语句来获取公司名称和一个特定标签的值。首先,第一个子查询从表dw_cg_profile.app_cust_company_base_info_profile_df中选择公司名称作为字符串,并只选择日期为`${date}`的记录。然后,第二个子查询从表dw_cg_profile.app_xingyao_account_profile_for_push_df中选择账户ID和标记4600的值作为列实体3标记4985,并将其与第一个子查询中的公司名称和排名号码JOIN在一起,以便每个公司名称只有一个排名号码,并且排名号码按行号排序。最后,SELECT语句选择t_main.company_name和column_entity3_tag4985这两个列,其中t_main表示第一个子查询中的公司名称,而column_entity3_tag4985表示第二个子查询中的列实体3标记4985的值。
阅读全文