1.创建数据库
create database db_cart;

2.使用数据库
use db_cart;

3.创建表
create table t_cart(
province STRING,
month INT,
city STRING,
county STRING,
year INT,
cartype STRING,
productor STRING,
brand STRING,
mold STRING,
owner STRING,
nature STRING,
number INT,
ftype STRING,
outv INT,
power DOUBLE,
fuel STRING,
length INT,
width INT,
height INT,
xlength INT,
xwidth INT,
xheight INT,
count INT,
base INT,
front INT,
norm STRING,
tnumber INT,
total INT,
curb INT,
hcurb INT,
passenger STRING,
zhcurb INT,
business STRING,
dtype STRING,
fmold STRING,
fbusiness STRING,
name STRING,
age INT,
sex STRING)
row format delimited
fields terminated by '\t'
location '/cart/log';

4.加载数据
load data local inpath '/root/cars.txt' into table t_cart;

需求:
1.1、通过统计车辆不同用途的数量分布
第一种情况:
select nature,sum(number)
from t_cart
group by nature
having nature is not null
and nature <> '';

第二种情况:
select '非营运' sum(if(nature='非营运',number,0)),
'营运' sum(if(nature<>'非营运',number,0))
from t_cart
where nature is not null and nature <> '';

1.2、统计山西省 2013 年每个月的汽车销售数量的比例
select a.year,a.month,a.counts/b.sums
from
(select year,month,sum(number) counts
from t_cart
group by year,month
having month is not null
and year is not null)a,
(select year,sum(number)  sums
from t_cart
where year=2013
group by year)b;

1.3、统计山西省 2013 年各市、区县的汽车销售的分布
select year,city,county,sum(number)
from t_cart
where year=2013
group by city,county
having city is not null and city <> ''
and county is not null and county <> '';

2、用户数据市场分析:
2.1、统计买车的男女比例
性别:
女 0
男 1
select a.sex,a.counts/b.sums
from
(select sex,sum(number) counts
from t_cart
group by sex
having sex is not null and sex <> '') a,
(select sum(number) sums
from t_cart
where sex is not null and sex <> '')b;

2.2、统计的车的所有权、车辆类型和品牌的分布
brand STRING,品牌
mold STRING,车辆类型
owner STRING,所有权

select brand,mold,owner,sum(number)
from t_cart
group by brand,mold,owner
having brand is not null and brand <> ''
and mold is not null and mold <> ''
and owner is not null and owner <> '';

3、不同车型销售统计分析:
3.1、统计不同品牌的车在每个月的销售量分布(数量)

select month,brand,sum(number)
from t_cart
group by brand,month
having brand is not null and brand <> ''
and month is not null;

3.2、通过不同类型(品牌)车销售情况,来统计发动机型号和燃料种类(数量)
ftype STRING,发动机型号
fuel STRING,燃料种类

select brand,count(ftype),count(fuel)
from t_cart
group by brand,ftype,fuel
having brand is not null and brand <> ''
and ftype is not null and ftype <> ''
and fuel is not null and fuel <> '' ;

山西汽车销量(hive)的更多相关文章

  1. [转帖]Speed-BI数据分析案例:2016年8月汽车销量排行榜

    [转帖]Speed-BI数据分析案例:2016年8月汽车销量排行榜 据中国汽车工业协会统计分析,2016年8月,乘用车市场表现较好,当月销量环比和同比均呈较快增长.1-8月,乘用车销量总体呈稳定增长, ...

  2. Speed-BI数据分析案例:2016年7月汽车销量排行榜

    据中国汽车工业协会统计分析,2016年7月,汽车产销比上月均呈下降,同比呈较快增长.1-7月,汽车产销保持稳定增长,增幅比上半年继续提升. 7月,汽车生产195.96万辆,环比下降4.38%,同比增长 ...

  3. Speed-BI数据分析案例:2016年8月汽车销量排行榜

    据中国汽车工业协会统计分析,2016年8月,乘用车市场表现较好,当月销量环比和同比均呈较快增长.1-8月,乘用车销量总体呈稳定增长,增幅比1-7月继续小幅提升.      8月,乘用车共销售179.5 ...

  4. Captain technology INC:全球新能源汽车格局突变

    美国能源信息署EIA的统计数据显示,2020年上半年全美含纯电动和插电混动在内的新能源乘用车总销量仅为11.1万辆,同比缩水25%.虽然特斯拉在第三季度靠着13.93万辆的销量迎来了环比387%.同比 ...

  5. python爬虫——汽车之家数据

    相信很多买车的朋友,首先会在网上查资料,对比车型价格等,首选就是"汽车之家",于是,今天我就给大家扒一扒汽车之家的数据: 一.汽车价格: 首先获取的数据是各款汽车名称.价格范围以及 ...

  6. Covid经济型自主汽车

    Covid经济型自主汽车 Autonomous Vehicles in Covid Economy Covid经济已经对汽车行业产生了负面影响,更多的变化正在进行中,同时也带来了大量的不确定性.我们可 ...

  7. ElasticSearch聚合

    前言 说完了ES的索引与检索,接着再介绍一个ES高级功能API – 聚合(Aggregations),聚合功能为ES注入了统计分析的血统,使用户在面对大数据提取统计指标时变得游刃有余.同样的工作,你在 ...

  8. 【 D3.js 入门系列 --- 4 】 如何使用scale(比例)

    在上一节中使用了一个很重要的概念 — scale (这个不知道翻译成什么,暂且叫它比例).本节将重点介绍它的相关使用方法. 在介绍 scale 之前,先介绍两个经常和 scale 一起出现的函数,在上 ...

  9. 解读Gartner《2015年度新兴技术成熟度曲线报告》

    详细见:http://www.360doc.com/content/16/0209/16/26186435_533443133.shtml 今年的报告评估了112个领域超过2000项新型技术的市场类型 ...

随机推荐

  1. js防抖和节流优化浏览器滚动条滚动到最下面时加载更多数据

    防抖和节流,主要是用来防止过于平凡的执行某个操作,如浏览器窗口变化执行某个操作,监听某个input输入框keyup变化,瀑布流布局时Y轴滚动,图片加载. js函数的防抖 经过一段事件才执行某个操作,如 ...

  2. Houdini:也许是你未曾听过的最振奋人心的 CSS 进化

    原文链接:Houdini: Maybe The Most Exciting Development In CSS You’ve Never Heard Of更多译文将陆续推出,欢迎点赞+收藏+关注我的 ...

  3. jQuery学习总结06-插件开发

    本文是参考了Joey的博客后整理的. 先从一个简单扩展jQuery对象的demo开始说起: //sample:扩展jquery对象的方法,redTextColor()用于改变字体颜色. (functi ...

  4. python基础知识的入门介绍

    一.什么是编程语言 任何词语都是一种高度的概括和总结,所以找关键字.如下: (1)1.什么是"语言":一个人与另一个人沟通的介质 2人将自己的思维逻辑和想法通过计算机能过识别的语言 ...

  5. 使用vim打造python-ide

    一.前言 一直希望在linux下进行python开发,但是linux不想启动图形化界面,所以干脆直接用上了万能的VIM,用VIM打造了属于自己的python-IDE 二.插件 标签导航(tagbar和 ...

  6. Codeforces 918 括号匹配 SGdp[i][j][k]

    A B C #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) ...

  7. [git]git的分支管理

    最近在折腾git,有感于git这个强大而好用的版本管理工具. 说说git分支管理的心得体会. 首先,要有个master主分支: Git主分支的名字,默认叫做Master.它是自动建立的,版本库初始化以 ...

  8. Stylus-富有表现力的、动态的、健壮的CSS

    今天总结一下Stylus记一些常用的也是最基本的用法 一.  选择器 Stylus是基于缩进的这让我们可以更快捷的编写css比如 body { margin:; paddind:; font-size ...

  9. RabbitMQ发送消息成功,但是接受不到消息

    commom模块为mq配置模块 分了多模块后消息队列无法自动创建,发现原因竟然是SpringBoot没有扫描到common模块内的配置类. 我们在XxxApplication启动类上添加@Compon ...

  10. CF547E Mike and Friends

    子串看起来就很SuffixStructures 于是上SAM 本来想着直接LCT 后来发现没法串定位(暴力匹配复杂度不对) 然后就离线吧,先建出来然后链加子树和,树剖就odk. 其实更直接的套路是线段 ...