乘用车辆和商用车辆销售数据分析

数据样本
1 临汾市 尧都区 SY6370C1SBW 金杯 小型普通客车 个人 非营运 1 DL465Q5 汽油 男性

//建表
create table carsdata(month int,city string,area string,car_model string,brand string,car_type string,owner string,useage string,number int,engine string,gasoline string,sex string)row format delimited fields terminated by '\t';

//加载数据
load data local inpath '/root/cars' into table carsdata;

4.1汽车行业市场分析:
1统计乘用车辆和商用车辆的数量(即非营运和营运车辆)

select useage,count(*) from carsdata group by useage;
+---------+--------+--+
| useage  |  _c1   |
+---------+--------+--+
| 公交客运    | 56     |
| 公路客运    | 2      |
| 出租客运    | 1      |
| 幼儿校车    | 1      |
| 非营运     | 21468  |
+---------+--------+--+

2统计山西省2013年每个月的汽车销售数量的比例

select month,count(*) from carsdata group by month;
+--------+-------+--+
| month  |  _c1  |
+--------+-------+--+
| 1      | 2281  |
| 2      | 1381  |
| 3      | 1804  |
| 4      | 1372  |
| 5      | 1731  |
| 6      | 1396  |
| 7      | 1594  |
| 8      | 1610  |
| 9      | 1697  |
| 10     | 2228  |
| 11     | 2164  |
| 12     | 2270  |
+--------+-------+--+

4.2 用户数据市场分析:
1 统计买车的男女比例

select sex,count(*) as count from carsdata group by sex;
+---------+--------+--+
|   sex   | count  |
+---------+--------+--+
|         | 352    |
| 天然气     | 117    |
| 柴油      | 420    |
| 汽油      | 20302  |
| 汽油|CNG  | 9      |
| 汽油|天然气  | 21     |
| 汽油天然气   | 79     |
| 混合动力    | 22     |
| 电       | 206    |
+---------+--------+--+

2 统计的车的所有权、型号和类型

select owner,car_model,car_type,count(*) as count from carsdata group by owner,car_model,car_type;

4.3 不同车型销售统计分析:
1 统计不同类型车在一个月(对一段时间:如每个月或每年)的总销售量

select car_type,month,count(*) as count from carsdata group by car_type,month;
+-----------+--------+--------+--+
| car_type  | month  | count  |
+-----------+--------+--------+--+
|           | 1      | 459    |
|           | 2      | 302    |
|           | 3      | 355    |
| 中型专用校车    | 7      | 1      |
| 中型普通客车    | 1      | 8      |
| 中型普通客车    | 2      | 6      |
| 中型普通客车    | 3      | 6      |
| 中型普通客车    | 4      | 15     |
| 中型普通客车    | 5      | 9      |
| 中型普通客车    | 6      | 11     |
| 中型普通客车    | 7      | 9      |
| 中型普通客车    | 8      | 33     |
| 中型普通客车    | 9      | 12     |
| 中型普通客车    | 10     | 29     |
| 中型普通客车    | 11     | 16     |
| 中型普通客车    | 12     | 16     |
| 中型越野客车    | 12     | 1      |
| 大型普通客车    | 1      | 1      |
| 大型普通客车    | 3      | 1      |
| 大型普通客车    | 5      | 2      |
| 大型普通客车    | 6      | 2      |
| 大型普通客车    | 7      | 1      |
| 大型普通客车    | 8      | 1      |
| 大型普通客车    | 10     | 2      |
| 大型普通客车    | 11     | 1      |
| 大型普通客车    | 12     | 6      |
| 小型普通客车    | 1      | 1812   |
| 小型普通客车    | 2      | 1073   |
| 小型普通客车    | 3      | 1442   |
| 小型普通客车    | 4      | 1357   |
| 小型普通客车    | 5      | 1720   |
| 小型普通客车    | 6      | 1382   |
| 小型普通客车    | 7      | 1583   |
| 小型普通客车    | 8      | 1576   |
| 小型普通客车    | 9      | 1685   |
| 小型普通客车    | 10     | 2197   |
| 小型普通客车    | 11     | 2147   |
| 小型普通客车    | 12     | 2247   |
| 微型普通客车    | 1      | 1      |
| 微型普通客车    | 6      | 1      |
+-----------+--------+--------+--+

2 通过不同类型(品牌)车销售情况,来统计发动机型号和燃料种类

select brand,engine,gasoline,count(*) from carsdata group by brand,engine,gasoline;

5 针对某一品牌的竞争分析:
1 统计五菱每一个月的销售量

select month,brand,count(*) from carsdata group by month,brand having brand='五菱';
+--------+--------+-------+--+
| month  | brand  |  _c2  |
+--------+--------+-------+--+
| 1      | 五菱     | 806   |
| 2      | 五菱     | 530   | 牛逼
| 3      | 五菱     | 670   |
| 4      | 五菱     | 485   |
| 5      | 五菱     | 943   |
| 6      | 五菱     | 767   |
| 7      | 五菱     | 892   |
| 8      | 五菱     | 918   |
| 9      | 五菱     | 1033  |
| 10     | 五菱     | 1348  |
| 11     | 五菱     | 1269  |
| 12     | 五菱     | 1364  |
+--------+--------+-------+--+

你可能感兴趣的:(个人练习)