--'Solar->', 'Grid->', '->Load', '->Battery'
.echo on
.open 'ramdisk/aiox.db'
attach 'aiox.db' as ssd;
select load_extension('/usr/lib/arm-linux-gnueabihf/libsqlitefunctions.so');  --rpi


select date(dt) as day, min(dt), max(dt), count(*), systemstatusid as Id,   max(Epv1_today) as Solar, Eac_chrToday + Eac_dischrToday as Grid,  Eop_dischrToday as Load, Ebat_dischrToday as Battery  from ir UNION select date(dt) as day, min(dt), max(dt), count(*), systemstatusid as Id,  max(Epv1_today) as Solar, Eac_chrToday + Eac_dischrToday as Grid,  Eop_dischrToday as Load, Ebat_dischrToday as Battery  from ssd.ir where systemstatusid = '12'  group by day, systemstatusid order by min(dt) desc limit 30;

