|NO.Z.00015|——————————|BigDataEnd|——|Hadoop&OLAP_Druid.V15|——|Druid.v15|实战|Druid实战案例.V4|

一、启动kafka生产者加载数据流
### --- 查询数据流记录总数

~~~     # 查记录总数
select count(*) as recordcount from yanqidruid2
### --- 查订单总数

~~~     # 查订单总数
select count(distinct orderId)  as orderscount from yanqidruid2
### --- 查有多少用户数

~~~     # 查有多少用户数
select count(distinct userId)  as usercount from yanqidruid2
### --- 统计各种订单状态的订单数

~~~     # 统计各种订单状态的订单数
select orderStatus, count(*) from ( select orderId, orderStatus
from yanqidruid2 group by orderId, orderStatus ) group by orderStatus
### --- 统计各种支付方式的订单数

~~~     # 统计各种支付方式的订单数
select payMode, count(1) from ( select orderId, payMode from yanqidruid2
group by orderId, payMode ) group by payMode
### --- 订单金额最大的前10名

~~~     # 订单金额最大的前10名
select orderId, payment, count(1) as productcount, sum(productNum) as products
from yanqidruid2 group by orderId, payment order by payment desc limit 10
### --- 计算每秒订单总金额

~~~     # 计算每秒订单总金额
select timesec, round(sum(payment)/10000, 2) from (
select date_trunc('second', __time) as timesec, orderId, payment
from yanqidruid2 group by date_trunc('second', __time), orderId, payment) group by timesec
二、查询计算SQL参考
### --- 查询计算

~~~     SQL参考:https://druid.apache.org/docs/0.19.0/querying/sql.html#data-types

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on 2022-04-14 15:24  yanqi_vip  阅读(12)  评论(0)    收藏  举报

导航