forked from s045pd/DarkNet_ChineseTrading
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grafana.sql
55 lines (44 loc) · 1.78 KB
/
grafana.sql
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
select
UNIX_TIMESTAMP(DATE_FORMAT(uptime,'%Y-%m-%d')) as time_sec,
count(*) as value ,
'darknet' as metric
from darknet_datasale
GROUP BY DATE_FORMAT(uptime,'%Y-%m-%d')
ORDER BY metric desc
SELECT
UNIX_TIMESTAMP(uptime) as time_sec,
count(*) as value,
(case
when CONVERT(Time_format(uptime,'%H'),SIGNED) <= 6 THEN "0点-6点"
when CONVERT(Time_format(uptime,'%H'),SIGNED) > 6 and CONVERT(Time_format(uptime,'%H'),SIGNED) <= 12 THEN "6点-12点"
when CONVERT(Time_format(uptime,'%H'),SIGNED) > 12 and CONVERT(Time_format(uptime,'%H'),SIGNED) <= 18 THEN "12点-18点"
when CONVERT(Time_format(uptime,'%H'),SIGNED) > 18 Then "18点-24点"
end) as metric
FROM darknet_datasale
WHERE $__timeFilter(uptime)
group by (case
when CONVERT(Time_format(uptime,'%H'),SIGNED) <= 6 THEN "0点-6点"
when CONVERT(Time_format(uptime,'%H'),SIGNED) > 6 and CONVERT(Time_format(uptime,'%H'),SIGNED) <= 12 THEN "6点-12点"
when CONVERT(Time_format(uptime,'%H'),SIGNED) > 12 and CONVERT(Time_format(uptime,'%H'),SIGNED) <= 18 THEN "12点-18点"
when CONVERT(Time_format(uptime,'%H'),SIGNED) > 18 Then "18点-24点"
end)
ORDER BY value desc
SELECT
UNIX_TIMESTAMP(uptime) as time_sec,
count(*) as value,
(case
when priceUSDT <= 1 THEN "$1以下"
when priceUSDT > 1 and priceUSDT <= 20 THEN "$1-$20"
when priceUSDT > 20 and priceUSDT <=100 THEN "$20-$100"
when priceUSDT > 100 Then "大于$100"
end) as metric
FROM darknet_datasale
WHERE $__timeFilter(uptime)
group by (case
when priceUSDT <= 1 THEN "$1以下"
when priceUSDT > 1 and priceUSDT <= 20 THEN "$1-$20"
when priceUSDT > 20 and priceUSDT <=100 THEN "$20-$100"
when priceUSDT > 100 Then "大于$100"
end)
ORDER BY uptime ASC
select uptime,hot,title,sold,priceUSDT from darknet_datasale order by uptime desc ;