计算太阳能逆变器的日耗电量

laximzn5  于 2021-06-18  发布在  Mysql
关注(0)|答案(2)|浏览(303)

我从太阳能逆变器读取数据并将其存储到mysql数据库中
该表有两个字段dtime记录日期和时间,ac\U output\U OPERNATIVE\U power记录电流负载(瓦特)。
我需要的是这样计算总的日耗电量(示例):

date        kWh
2018-10-24  1.3
2018-10-10 0.700
2018-10-09 2.2

等等。。。
我试过:

SELECT date(dtime),hour(dtime),((avg(AC_Output_Apparent_Power) *1)/1000) as kWh 
FROM `logs` 
WHERE AC_Output_Apparent_Power > 0 
GROUP by date(dtime),hour(dtime) 
order by dtime desc

结果是每小时消耗量:

date       hour     kWh     
2018-10-25  2   0.20880952
2018-10-25  1   0.23985294
2018-10-24  18  0.29619231
2018-10-23  6   0.11400000
2018-10-22  6   0.13800000
2018-10-22  2   0.13800000
2018-10-18  1   0.13800000
2018-10-16  10  0.09200000
2018-10-15  13  0.09100000
2018-10-14  21  0.13800000
2018-10-13  22  0.13700000
2018-10-13  8   0.09200000
2018-10-12  6   0.18966667
2018-10-12  5   0.17800000
2018-10-12  4   0.13800000
2018-10-10  15  0.25100000
2018-10-10  14  0.61285714
2018-10-09  18  0.13800000
2018-10-09  1   0.15150000
2018-10-04  5   0.14728947
2018-10-04  4   0.15062500
2018-10-04  3   0.14927778
2018-10-04  2   0.14958974
2018-10-04  1   0.14726744
2018-10-04  0   0.14886207

mysql表有这些值。
注意:正如您所见,在我进行测试时,数据没有定期读取

SELECT dtime,AC_Output_Apparent_Power FROM `logs` WHERE AC_Output_Apparent_Power > 0 order by dtime desc 

dtime                  AC_Output_Apparent_Power     
2018-10-24 18:20:25     152
2018-10-24 18:20:02     174
2018-10-24 18:19:50     174
2018-10-24 18:19:38     174
2018-10-24 18:19:26     173
2018-10-24 18:19:03     174
2018-10-24 18:18:51     154
2018-10-24 18:18:04     174
2018-10-24 18:17:53     175
2018-10-24 18:17:46     174
2018-10-24 18:17:29     175
2018-10-24 18:17:17     175
2018-10-24 18:17:05     174
2018-10-24 18:16:53     174
2018-10-24 18:16:48     174
2018-10-24 18:16:18     816
2018-10-24 18:15:54     174
2018-10-24 18:15:42     174
2018-10-24 18:15:30     852
2018-10-24 18:15:18     173
2018-10-24 18:15:07     174
2018-10-24 18:14:55     1084
2018-10-24 18:14:32     174
2018-10-24 18:14:26     173
2018-10-24 18:13:33     176
2018-10-24 18:13:21     152
2018-10-24 18:13:09     175
2018-10-24 18:12:58     174
2018-10-24 18:12:47     939
2018-10-24 18:12:37     174
2018-10-24 18:12:30     175
2018-10-24 18:11:48     815
2018-10-24 18:11:01     880
2018-10-24 18:10:49     924
2018-10-24 18:10:37     753
2018-10-24 18:10:13     154
2018-10-24 18:10:01     176
2018-10-24 18:09:50     174
2018-10-24 18:09:38     175
2018-10-24 18:09:26     176
2018-10-24 18:09:15     176
2018-10-24 18:09:03     176
2018-10-24 18:08:52     154
2018-10-24 18:08:40     176
2018-10-24 18:08:27     176
2018-10-24 18:08:16     176
2018-10-24 18:08:04     928
2018-10-24 18:07:52     176
2018-10-24 18:07:41     177
2018-10-24 18:07:29     176
2018-10-24 18:07:17     177
2018-10-24 18:06:54     178
2018-10-23 06:06:12     114
2018-10-22 06:49:01     138
2018-10-22 02:00:29     138
2018-10-18 01:47:54     138
2018-10-16 10:04:14     92
2018-10-15 13:59:27     91
2018-10-14 21:59:44     138
2018-10-13 22:01:48     137
2018-10-13 08:37:37     92
2018-10-13 08:02:43     92
2018-10-12 06:05:53     190
2018-10-12 06:05:41     190
2018-10-12 06:03:08     189
2018-10-12 05:58:59     166
2018-10-12 05:58:12     190
2018-10-12 04:31:56     138
2018-10-10 15:08:31     241
2018-10-10 15:06:34     370
2018-10-10 15:05:35     239
2018-10-10 15:03:02     154
2018-10-10 14:58:41     864
2018-10-10 14:58:16     456
2018-10-10 14:58:07     415
2018-10-10 14:57:53     545
2018-10-10 14:57:41     714
2018-10-10 14:56:43     1300
2018-10-10 14:56:22     949
2018-10-10 14:55:55     608
2018-10-10 14:55:45     522
2018-10-10 14:54:45     415
2018-10-10 14:54:34     431
2018-10-10 14:54:10     503
2018-10-10 14:53:47     506
2018-10-10 14:53:35     438
2018-10-10 14:53:23     417
2018-10-10 14:45:43     874
2018-10-10 14:45:31     442
2018-10-10 14:45:08     710
2018-10-10 14:44:19     421
2018-10-10 14:44:07     604
2018-10-10 14:40:23     736
2018-10-09 18:05:58     138
2018-10-09 01:05:55     153
2018-10-09 01:05:29     153
2018-10-09 01:05:04     152
2018-10-09 01:04:40     151
2018-10-09 01:04:13     151
2018-10-09 01:03:47     152

瓦特-千瓦时计算电能e(千瓦时)等于功率p(瓦时),乘以时间段t(小时)除以1000:
e(kwh)=p(w)× t(小时)/1000
如何计算总日耗电量而不是每小时。
欢迎任何建议。提前谢谢。

dz6r00yl

dz6r00yl1#

SELECT CONVERT_TZ(`timestamp`, @@session.time_zone, '+00:00') AS `time`,
       AVG(value / 1000) as "value",
       name as "metric" -- phase / line
FROM `power` 
WHERE name IN ("PhaseA_Energy", "PhaseB_Energy", "PhaseC_Energy")
AND $__timeFilter(timestamp)
GROUP BY date_format( timestamp, '%Y-%m-%d %H' ), name
p8h8hvxi

p8h8hvxi2#

你到底想要什么还不清楚。
但我的方法是:
http://sqlfiddle.com/#!9/6d5bef/6号

SELECT date(dtime),(SUM(AC_Output_Apparent_Power)/1000) as kW
FROM `logs` 
WHERE AC_Output_Apparent_Power > 0 
GROUP by date(dtime)
order by dtime desc ;

请提供预期结果集。

相关问题