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. mingetty - 控制台最小的 getty

    总览 SYNOPSIS mingetty [--noclear] [--nonewline] [--noissue] [--nohangup] [--nohostname] [--long-hostn ...

  2. 025-Cinder服务-->安装并配置一个本地存储节点(ISCSI)

    一:Cinder提供块级别的存储服务,块存储提供一个基础设施为了管理卷,以及和OpenStack计算服务交互,为实例提供卷.此服务也会激活管理卷的快照和卷类型的功能,块存储服务通常包含下列组件:cin ...

  3. New Machine Learning Server for Deep Learning in Nuke(翻译)

    最近一直在开发Orchestra Pipeline System,歇两天翻译点文章换换气.这篇文章是无意间看到的,自己从2015年就开始关注机器学习在视效领域的应用了,也曾利用碎片时间做过一些算法移植 ...

  4. 【洛谷P3959】宝藏

    题目大意:比较复杂,点 这里 看题. 题解:对于状态压缩 dp 来讲,阶段的确立十分重要.本题中,采用以层次为阶段进行状压 dp. 设状态 \(f[i][S]\) 表示开凿到深度 \(i\),当前已经 ...

  5. ppt打不开,显示发现文件中的内容有问题。可尝试修复此演示文稿

    原因分析 主要是因为文件是网络下载的,office自动锁定了文件(默认不可编辑). 解决办法 在文件上右键-属性-解除锁定(最下面),就不会进行检查了,问题也就解决了. ppt文件---右键---属性 ...

  6. watch和computed

    watch和computed都是以Vue的依赖追踪机制为基础的,它们都试图处理这样一件事情:当某一个数据(称它为依赖数据)发生变化的时候,所有依赖这个数据的“相关”数据“自动”发生变化,也就是自动调用 ...

  7. Excel: assign label to scatter chart using specific cell values

    ref: https://www.get-digital-help.com/custom-data-labels-in-x-y-scatter-chart/ Improve your X Y Scat ...

  8. RSA和AES工具类

    AESUtil import com.xxx.common.BssException; import com.xxx.common.constants.CommonConstants; import ...

  9. CSS元素居中汇总

    总结实现不同类型元素居中的几种方法: 一.把margin值设置为auto(实现水平居中) 可以实现元素水平居中对齐 原理:使  margin-left=margin-right  如果设置  marg ...

  10. computed属性和watcher

    computed属性 在模板中使用表达式是非常方便直接的,然而这只适用于简单的操作.在模板中放入太多的逻辑,会使模板过度膨胀和难以维护.例如: <div id="example&quo ...