|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   yanqi_vip  阅读(6)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示