I have records of smartmeter in an mysql database.
Records in timestamp order looking in generall as follow:
key | timestamp | watt now |
---|---|---|
000001 | 2022-10-04-01-01-01 | 10 |
000002 | 2022-10-04-01-02-01 | 10 |
000003 | 2022-10-04-01-03-01 | 101 |
000004 | 2022-10-04-01-04-01 | 101 |
000005 | 2022-10-04-01-05-01 | 102 |
000006 | 2022-10-04-01-06-01 | 101 |
000007 | 2022-10-04-01-07-01 | 102 |
000008 | 2022-10-04-01-08-01 | 10 |
000009 | 2022-10-04-01-09-01 | 10 |
000010 | 2022-10-04-01-09-01 | 10 |
000011 | 2022-10-04-01-09-01 | 107 |
000012 | 2022-10-04-01-09-01 | 101 |
000013 | 2022-10-04-01-09-01 | 109 |
000014 | 2022-10-04-01-09-01 | 10 |
000015 | 2022-10-04-01-09-01 | 10 |
I want to identify the groups with bigger number (lets say > 100) and give them an incresing id. Also I want to get per group the first and last key id
Result of query should look like this:
month | day | numbers of group | first id | last id | average watt |
---|---|---|---|---|---|
10 | 04 | 0 | 000003 | 000007 | 102 |
10 | 04 | 1 | 000011 | 0000013 | 105 |
Any help apreciated