需求:
不同地区下的订单金额数
select bp.region_name,sum(sku_num) from dwd_order_detail
od join dim_base_province bp on od.province_id=bp.id
group by bp.region_name;
实现每日构建Cube:https://blog.csdn.net/weixin_45417821/article/details
BI工具集成
https://blog.csdn.net/weixin_45417821/article/details
JDBC代码:
package com.kylin;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class Gmall_Kylin {
public static void main(String[] args) throws Exception{
//Kylin_JDBC 驱动
String KYLIN_DRIVER = "org.apache.kylin.jdbc.Driver";
//Kylin_URL
String KYLIN_URL = "jdbc:kylin://hadoop102:7070/gmall";
//Kylin的用户名
String KYLIN_USER = "ADMIN";
//Kylin的密码
String KYLIN_PASSWD = "KYLIN";
//添加驱动信息
Class.forName(KYLIN_DRIVER);
//获取连接
Connection connection = DriverManager.getConnection(KYLIN_URL, KYLIN_USER, KYLIN_PASSWD);
//预编译SQL
String sql = "select bp.region_name,sum(sku_num) from dwd_order_detail od join dim_base_province bp on od.province_id=bp.id group by bp.region_name";
PreparedStatement ps = connection.prepareStatement(sql);
//执行查询
ResultSet resultSet = ps.executeQuery();
//遍历打印
while (resultSet.next()) {
System.out.println(resultSet.getString(1) + ":" + resultSet.getInt( 2 ));
}
}
}
代码结果如下: