当前位置: 首页 > news >正文

网站文件夹权限设置深圳公司注销

网站文件夹权限设置,深圳公司注销,爱站seo查询,济南软件外包背景#xff1a;这是尚硅谷SparkSQL练习题#xff0c;本文用HiveSQL进行了实现。 数据集#xff1a;用户点击表#xff0c;商品表#xff0c;城市表 题目: ① 求每个地区点击量前三的商品#xff1b; ② 在①的基础上#xff0c;求出每个地区点击量前三的商品后这是尚硅谷SparkSQL练习题本文用HiveSQL进行了实现。 数据集用户点击表商品表城市表 题目: ① 求每个地区点击量前三的商品 ② 在①的基础上求出每个地区点击量前三的商品后求出每个商品中的点击量前三的城市分别占本商品总点击量的百分比。 建表导入数据 没啥说的建表语句直接抄过来 use atguigu;CREATE TABLE user_visit_action(date string,user_id bigint,session_id string,page_id bigint,action_time string,search_keyword string,click_category_id bigint,click_product_id bigint,order_category_ids string,order_product_ids string,pay_category_ids string,pay_product_ids string,city_id bigint) row format delimited fields terminated by \t;load data local inpath datas/user_visit_action.txt into table atguigu.user_visit_action;CREATE TABLE product_info(product_id bigint,product_name string,extend_info string) row format delimited fields terminated by \t;load data local inpath datas/product_info.txt into table atguigu.product_infoCREATE TABLE city_info(city_id bigint,city_name string,area string) row format delimited fields terminated by \t;load data local inpath datas/city_info.txt into table atguigu.city_info;查询 第一问求每个地区点击量前三的商品 分析按 areaproduct_name 两个字段分组求出点击量click_ct2保留每个地区点击量前三的商品。 selectarea,product_name,click_ct2 from (selectarea,product_name,click_ct2,row_number() over( partition by area order by click_ct2 desc ) as rn2from (selectarea,product_name,count(*) as click_ct2from (selecta.*,p.product_name,c.area,c.city_namefrom user_visit_action ajoin product_info p on a.click_product_id p.product_idjoin city_info c on a.city_id c.city_idwhere a.click_product_id -1) t1 group by area, product_name) t2 ) t3 where rn2 3第二问 在①的基础上求出每个地区点击量前三的商品后求每个商品中的点击量前三的城市分别占本商品总点击量的百分比。 分析 第一问求出了每个地区、每个商品的点击量这个点击量叫click_ct2并取了每个地区前三名的商品。 在第二问中可以先求出每个地区、每个商品、每个城市的点击量这个点击量叫click_ct3取每个地区、每个商品点击量的前三名城市。 用click_ct3/click_ct2就是每个地区、每个商品、每个城市点击率这个点击率叫click_rate3。 click_ct3所在的临时表叫tmp1click_ct2所在的临时表叫tmp2。 tmp1有三个维度粒度更细数据条数会更多tmp2有两个维度粒度粗数据条数少。 无论是tmp1 join tmp2还是tmp2 join tmp1两种方式都可以tmp1中不符合条件的数据会被筛掉。 之后用concat()将每行的城市名和点击率拼接在一起 再按地区、商品、总点击量进行分组用collect_set()收集每组拼接的结果 将收集的结果拼接成字符串再转换成map。 --维度area,city_name,product_name --度量点击次数 --限定前三 with tmp1 as(select area,product_name,city_name,click_ct3from(select area,city_name,product_name,click_ct3,row_number()over(partition by area,product_name order by click_ct3) rn1from(select area,city_name,product_name,count(*) click_ct3from(selecta.*,p.product_name,c.area,c.city_namefrom user_visit_action ajoin product_info p on a.click_product_id p.product_idjoin city_info c on a.city_id c.city_idwhere a.click_product_id -1)t1group by area,city_name,product_name)t2)t3where rn13order by area,product_name,city_name,click_ct3 desc ), --维度area,product_name --度量点击次数 --限定前三 tmp2 as(selectarea,product_name,click_ct2from (selectarea,product_name,click_ct2,row_number() over( partition by area order by click_ct2 desc ) as rn2from (selectarea,product_name,count(*) as click_ct2from (selecta.*,p.product_name,c.area,c.city_namefrom user_visit_action ajoin product_info p on a.click_product_id p.product_idjoin city_info c on a.city_id c.city_idwhere a.click_product_id -1) t1 group by area, product_name) t2) t3 where rn2 3 ) select area,product_name,click_ct2,-- 按地区、商品、总点击量进行分组用collect_set()收集每组拼接的结果-- 将收集后的结果转换成mapstr_to_map(concat_ws(,,collect_set(city_rate)),,,:) city_rate3 from(select area,product_name,click_ct2,click_rate,-- 将每行的城市名和点击率拼接在一起concat(city_name,:,click_rate,%) city_ratefrom(select tmp1.area,tmp1.product_name,tmp1.city_name,tmp2.click_ct2,round(tmp1.click_ct3*100/tmp2.click_ct2,2) click_ratefrom tmp2 join tmp1 on tmp2.areatmp1.area and tmp2.product_nametmp1.product_name)t1order by area,click_ct2 desc,click_rate desc )t2 group by area,product_name,click_ct2 order by area,click_ct2 desc
http://www.yutouwan.com/news/367670/

相关文章:

  • 南充网站建设天赐企业形象设计手册
  • 公司网站内容的更新免费关键词排名优化
  • 江西省寻乌县建设局网站手机网站页面如何制作
  • 苏州现在能去吗外贸网站如何推广优化
  • 我要看一集片做网站企业黄页网站源码
  • 注册公司网站基于h5的网站开发
  • 大型平面设计网站深圳app开发
  • 怎么做彩票网站代理网站维护公告模板
  • 百度工具网站改版网络公司具体是干什么的
  • 长春阿凡达网站建设网站设计与建设代码
  • 最好在线网站建设制作网站的公司办什么营业执照
  • 网站推广项目别人网站建设多少钱
  • 可以挣钱的设计网站百度竞价账户
  • 手机版网站建设多少钱庆阳手机网站设计
  • dede游戏网站模板国内crm系统十大排名
  • 后台管理网站名移动端ui
  • 深圳正规网站制作哪家公司好网络营销专业咋样
  • 圆梦科技专业网站建设做网站如何自己寻找客户
  • 专做山珍的网站app智能开发
  • 找别人做网站都需要注意啥wordpress被墙变慢
  • 中国空间站叫什么新乡最新消息
  • 河北省住房和城乡建设厅网站打不开网站的主要栏目及功能
  • 网站建设汇报方案pptwordpress 文章类主题
  • 有赞微商城开店收费吗网站seo快速优化
  • 网站建设有什么品牌如何制作自己的app
  • 游戏租号网站怎么建设上海黄页查询
  • 徐州做网站优化网站运营现状
  • 手机h5建网站网站顶部小图标怎么做
  • 哪个网站可以接做美工的活儿济南建网站公司价格
  • 嘉兴企业网站建设公司网站建设业务怎么跑