I have table mysql with column date, time, subject, description and value. I want to know the value at current day is increase or degrade from the value at last 7 day in the same time.
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|
The final expecting result:
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]
How to get the status of each Subject?
Meanwhile I use command LEFT JOIN, but the result was unexpected ...
Thanks
.. FROM table t1 [LEFT] JOIN table t2 ON t1.date = t2.date + INTERVAL 1 WEEK ...times.