标签:
六、Hue数据可视化实例-- 按产品分类查询销售量和销售额 select t2.product_category pro_category, sum(order_quantity) sum_quantity, sum(order_amount) sum_amount from sales_order_fact t1, product_dim t2 where t1.product_sk = t2.product_sk group by pro_category order by pro_category; -- 按产品查询销售量和销售额 select t2.product_name pro_name, sum(order_quantity) sum_quantity, sum(order_amount) sum_amount from sales_order_fact t1, product_dim t2 where t1.product_sk = t2.product_sk group by pro_name order by pro_name;点击“执行”按钮,结果显示按产品分类的销售统计,如下图所示。接着点击“下一页”按钮,结果会显示按产品的销售统计。
产品统计结果如下图所示。
-- 按州查询销售量和销售额 select t3.state state, count(distinct t2.customer_sk) sum_customer_num, sum(order_amount) sum_order_amount from sales_order_fact t1 inner join customer_dim t2 on t1.customer_sk = t2.customer_sk inner join customer_zip_code_dim t3 on t1.customer_zip_code_sk = t3.zip_code_sk group by state order by state; -- 按城市查询销售量和销售额 select t3.city city, count(distinct t2.customer_sk) sum_customer_num, sum(order_amount) sum_order_amount from sales_order_fact t1 inner join customer_dim t2 on t1.customer_sk = t2.customer_sk inner join customer_zip_code_dim t3 on t1.customer_zip_code_sk = t3.zip_code_sk group by city order by city;城市统计饼图如下图所示。
从图中可以看到,mechanicsburg市的销售占整个销售额的一半。
(8)再建立一个“按年月统计”的查询,这次使用动态表单功能,运行时输入年份。SQL语句如下。-- 按年月查询销售量和销售额 select t4.year*100 + t4.month ym, sum(order_quantity) sum_quantity, sum(order_amount) sum_amount from sales_order_fact t1 inner join order_date_dim t4 on t1.order_date_sk = t4.date_sk where (t4.year*100 + t4.month) between $ym1 and $ym2 group by ym order by ym;注意$ym1和$ym2是动态参数,执行此查询,会出现输入框要求输入参数,如下图所示。
[librdbms] [[databases]] [[[mysql]]] # Name to show in the UI. nice_name="MySQL DB" name=hive engine=mysql host=172.16.1.102 port=3306 user=root password=mypassword这里配置的是一个MySQL数据库,如下图所示。
此时再次在Hue里点击“Query Editors” -> “DB 查询”,则会出现MySQL中hive库表,此库存放的是Hive元数据。此时就可以输入SQL进行查询了,如下图所示。
基于hadoop生态圈的数据仓库实践 —— OLAP与数据可视化(六)
标签:
原文地址:http://blog.csdn.net/wzy0623/article/details/52386016