提问人:luckymanh_74yahoocom 提问时间:8/15/2023 最后编辑:Akinaluckymanh_74yahoocom 更新时间:8/15/2023 访问量:20
Mysql:如何比较当天和最近 7 天同一列中的值,当天的值是增加还是减少百分比。?
Mysql: How to compare value in the same column between current day and last 7 day, is the value in current day is increase or degrade in percentage .?
问:
我有表mysql,其中包含列日期,时间,主题,描述和值。我想知道当天的值是在同一时间从过去 7 天的值增加或减少。
Date Time Subject Description Value|
---------------------------------------------------------------------|
2023-08-10 20:03:00 DNS Gn/BRN DNS mem avail real 1089350|
2023-08-10 20:03:00 DNS Gn2 DNS mem total real 65601700|
2023-08-10 20:03:00 DNS Gn DNS mem total swap 25165800|
: : : : :
: : : : :
2023-08-17 20:03:00 DNS Gn DNS mem avail real 878044032|
2023-08-17 20:03:00 DNS Gn/BRN DNS mem avail real 8567809|
2023-08-10 20:03:00 DNS Gn2 DNS mem total real 6780408|
最终的预期结果:
Date Time Subject Subject1 Value Status|
------------------------------------------------------------------------|
2023-08-10 20:03:00 DNS Gn/BRN1 DNS mem avail real 10893500 ?|
2023-08-10 20:03:00 DNS Gn2 DNS mem total real 65601700 ?|
2023-08-10 20:03:00 DNS Gn DNS mem total swap 25165800 ?|
: : : : : |
: : : : : |
2023-08-17 20:03:00 DNS Gn DNS mem avail real 87804408 -30.84%| --> [(65601700-87804408)/65601700]
2023-08-17 20:03:00 DNS Gn/BRN1 DNS mem avail real 8567809 21.34%| --> [(10893500-8567809)/10893500]
2023-08-17 20:03:00 DNS Gn2 DNS mem avail real 6780408 75.06%|--> [(25165800-6780408)/25165800]
如何获取每个主题的状态?
同时我使用命令LEFT JOIN,但结果出乎意料......
谢谢
答: 暂无答案
评论
.. FROM table t1 [LEFT] JOIN table t2 ON t1.date = t2.date + INTERVAL 1 WEEK ..
.times