[Hive综合应用案例——用户学历查询

---------- 禁止修改 ----------drop database if exists mydb cascade;
---------- 禁止修改 -------------------- begin ----------
---创建mydb数据库create database if not exists mydb;
---使用mydb数据库
use mydb;---创建表user
create table   usertab(id string ,sex string  ,time string  ,education string  ,occupation string ,income string ,area string ,desired_area string,city_countryside string
)row format delimited fields terminated by ','; ---导入数据:/root/data.txt
load data local inpath '/root/data.txt' into table usertab;--查询每一个用户从出生到2019-06-10的总天数
select id,datediff('2019-06-10',regexp_replace(time,'/','-')) from usertab;---------- end ----------
-- create table  if not exists usertab(
--     id string comment '用户id',
--     sex string comment '性别,f:女性,m:男性',
--     time string comment '出生日期',
--     education string comment '学历',
--     occupation string comment '职业',
--     income string comment '收入',
--     area string comment '出生地区',
--     desired_area string comment '向往地区',
--     city_countryside string comment '超市/农村'
-- )row format delimited fields terminated by ','; 

---------- 禁止修改 ----------drop database if exists mydb cascade;
---------- 禁止修改 -------------------- begin ----------
--创建mydb数据库create database if not exists mydb;
---使用mydb数据库
use mydb;---创建表user
create table   usertab1(id int ,sex string  ,time string  ,education string  ,occupation string ,income string ,area string ,desired_area string,city_countryside string
)row format delimited fields terminated by ','; ---导入数据:/root/data.txt
load data local inpath '/root/data1.txt' into table usertab1;--同一个地区相同的教育程度的最高收入
select area,education,income from (
select area,education,income,
row_number() over(partition by area,education order by income desc)
as rn
from usertab1
)a where a.rn=1;---------- end ----------
-- select area,education,income from(
--     select area,education,income,
--     row_number() over(partition by area,education order by income desc) as rn
--     from usertab1
-- ) where a.rn=1;

---------- 禁止修改 ----------drop database if exists mydb cascade;set hive.mapred.mode=nonstrict;
---------- 禁止修改 -------------------- begin ----------
--创建mydb数据库create database if not exists mydb;
---使用mydb数据库
use mydb;---创建表user
create table   usertab2(id int ,sex string  ,time string  ,education string  ,occupation string ,income string ,area string ,desired_area string,city_countryside string
)row format delimited fields terminated by ','; ---导入数据:/root/data.txt
load data local inpath '/root/data.txt' into table usertab2;--统计各级学历所占总人数百分比(对结果保留两位小数)
select concat(round(a.cnted*100/b.cnt,2),'%'),a.education from(select count(*) as cnted,education from usertab2 group by education
)a ,(select count(*) as cnt from usertab2
)b order by a.education;-- select concat(round(a.cnt*100/a.cnt_total*100,2),'%')as ct,education from(
--     select count(*) over(partition by education) as cnt,
-- count(*) over as cnt_total,education,row_number() over(partition by education)
-- )a where a.rn=1 order by education;---------- end ----------

Hive综合应用案例——用户学历查询相关推荐

  1. 大数据从入门到实战——Hive综合应用案例 ——学生成绩查询

    Hive综合应用案例 - 学生成绩查询 第1关 计算每个班的语文总成绩和数学总成绩 第2关 查询选修了3门以上的课程的学生姓名 第3关 课程选修人数 第4关 shujuku课程的平均成绩 第1关 计算 ...

  2. Hive综合应用案例 — 学生成绩查询

    第1关:计算每个班的语文总成绩和数学总成绩 任务:计算每个班的语文总成绩和数学总成绩,要求有哪科低于60分,该名学生成绩不计入计算. 创建数据库:mydb 创建成绩表:score 字段名 类型 注释 ...

  3. web简单案例-用户信息查询

    文章目录 前言 一.所用jar包 二.整体框架 三.用户登录 3.1登录展示 3.2基本思路 3.3LoginServlet代码 四.用户列表展示 4.1 列表模糊查询+分页展示 4.2PageBea ...

  4. 2021年大数据Hive(十二):Hive综合案例!!!

    全网最详细的大数据Hive文章系列,强烈建议收藏加关注! 新文章都已经列出历史文章目录,帮助大家回顾前面的知识重点. 目录 系列历史文章 前言 Hive综合案例 一.需求描述 二.项目表的字段 三.进 ...

  5. 大数据课程综合实验案例:网站用户行为分析

    大数据课程综合实验案例 1 案例简介 1.1 案例目的 1.2 适用对象 1.3 时间安排 1.4 预备知识 1.5 硬件要求 1.6 软件工具 1.7 数据集 1.8 案例任务 1.9 实验步骤 2 ...

  6. JavaWeb-综合案例(用户信息)-学习笔记06【复杂条件查询功能】

    Java后端 学习路线 笔记汇总表[黑马程序员] JavaWeb-综合案例(用户信息)-学习笔记01[列表查询] JavaWeb-综合案例(用户信息)-学习笔记02[登录功能] JavaWeb-综合案 ...

  7. JavaWeb-综合案例(用户信息)-学习笔记05【分页查询功能】

    Java后端 学习路线 笔记汇总表[黑马程序员] JavaWeb-综合案例(用户信息)-学习笔记01[列表查询] JavaWeb-综合案例(用户信息)-学习笔记02[登录功能] JavaWeb-综合案 ...

  8. JavaWeb-综合案例(用户信息)-学习笔记01【列表查询】

    Java后端 学习路线 笔记汇总表[黑马程序员] JavaWeb-综合案例(用户信息)-学习笔记01[列表查询] JavaWeb-综合案例(用户信息)-学习笔记02[登录功能] JavaWeb-综合案 ...

  9. oracle高级查询案例,oracle高级查询(实例基于scott用户四张表)

    oracle高级查询(实例基于scott用户四张表) 分组查询 多表查询 子查询 综合实例 ====================================================== ...

  10. 搜狗日志查询分析 (MapReduce+Hive综合实验)

    前提条件: 安装好hadoop2.7.3(Linux系统下) 安装好MySQL(Windows或Linux系统下) 安装好Hive(Linux系统下)参考:Hive安装配置 题目: 从搜狗实验室下载搜 ...

最新文章

  1. GARFIELD@01-24-2005
  2. 图灵奖得主LeCun力推无监督学习:要重视基于能量的学习方法
  3. 算法提高课-图论-单源最短路的建图方式-AcWing 1129. 热浪:dijkstra裸题
  4. 定义交货类型的装运点确定规则
  5. 《linux就该这么学》第七节课:文件的各种权限以及linux分区命名规则
  6. 数据结构--散列表 Hash Table
  7. 【例题+习题】【数值计算方法复习】【湘潭大学】(三)
  8. Git学习笔记总结和注意事项
  9. Linux系统 nginx伪静态配置及nginx重启
  10. 叉积求点到平面距离_求一个点到曲线或折线的最短距离?
  11. pyltp安装及运行
  12. jaxl php,php – jaxl无法连接到Prosody
  13. android+特殊符号过滤,android 特殊符号过滤
  14. 刘寅:TiDB 工具链和生态
  15. 双非计算机硕士何去何从(1)
  16. RedHat安装yum和配置yum源
  17. 科普向-----验证码
  18. 准备走上共享软件之路,出师不利,两块石头石沉大海,我打算流了她们。
  19. 代谢组学通路富集分析
  20. PCL小工具二:使用kitti的GT(ground truth)建立激光点云地图

热门文章

  1. 2018中南大学 计算机考研分数,2018年中南大学考研复试分数线
  2. 井字棋(棋子可消去(拿走))
  3. 谷歌,互联网界的“彩蛋狂魔”
  4. 10 本 O'Reilly 出版的免费好书
  5. JavaScript键盘按键侦测
  6. R语言—Shiny框架
  7. 关于驱动程序与BSP的区别
  8. Android 自启项管理器工具
  9. AI基础:图解Transformer
  10. 我们编写的python代码在运行过程中_在 Rust 代码中编写 Python 是种怎样的体验?...