views kreiert
This commit is contained in:
1 parent
639b7669db
commit
e412111edb
2 files changed
+130
No files matched your search
+130
@@ -0,0 +1,130 @@
|
||||
drop view if exists gasroh;
|
||||
drop view if exists vgasroh;
|
||||
create view vgasroh as
|
||||
|
||||
SELECT id,zeitpunkt,gaszaehler,wetterinfo
|
||||
, CAST(replace(gaszaehler ,',','.') as float) as gasval,
|
||||
|
||||
lag ( CAST(replace(gaszaehler ,',','.') as float) ,1 ) over (order by id)
|
||||
as vorgasval
|
||||
|
||||
,
|
||||
case when
|
||||
round(
|
||||
( CAST(replace(gaszaehler ,',','.') as float)) - (lag ( CAST(replace(gaszaehler ,',','.') as float),1 ) over (order by id))
|
||||
,3)
|
||||
is null then 0.0
|
||||
else
|
||||
round(
|
||||
( CAST(replace(gaszaehler ,',','.') as float)) - (lag ( CAST(replace(gaszaehler ,',','.') as float),1 ) over (order by id))
|
||||
,3)
|
||||
end
|
||||
as gasvolumen
|
||||
|
||||
, ( julianday(zeitpunkt) - julianday ( ( lag(zeitpunkt,1) over (order by id) ) ) ) * 24.0
|
||||
as zeitspannestd
|
||||
|
||||
,
|
||||
( ( CAST(replace(gaszaehler ,',','.') as float)) - (lag ( CAST(replace(gaszaehler ,',','.') as float),1 ) over (order by id)) )
|
||||
/( ( julianday(zeitpunkt) - julianday ( ( lag(zeitpunkt,1) over (order by id) ) ) ) * 24.0 )
|
||||
* 24.0 as gasvolumen24
|
||||
|
||||
, 10.0 as gasfaktor
|
||||
|
||||
, case when
|
||||
( ( CAST(replace(gaszaehler ,',','.') as float)) - (lag ( CAST(replace(gaszaehler ,',','.') as float),1 ) over (order by id)) )
|
||||
/( ( julianday(zeitpunkt) - julianday ( ( lag(zeitpunkt,1) over (order by id) ) ) ) * 24.0 )
|
||||
is null then 0.0
|
||||
else
|
||||
10.0 * (
|
||||
( ( CAST(replace(gaszaehler ,',','.') as float)) - (lag ( CAST(replace(gaszaehler ,',','.') as float),1 ) over (order by id)) )
|
||||
/( ( julianday(zeitpunkt) - julianday ( ( lag(zeitpunkt,1) over (order by id) ) ) ) * 24.0 )
|
||||
* 24.0
|
||||
)
|
||||
|
||||
end
|
||||
as gasverbrauchKWhauf24
|
||||
|
||||
, cast ( substr(wetterinfo, 0,instr(wetterinfo,'°C|')) as float)
|
||||
as GradCelsiusAussen
|
||||
|
||||
from eintraege where gaszaehler>0 ;
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- ------------------------------------------------------------------------------
|
||||
|
||||
drop view if exists gassum;
|
||||
drop view if exists vgassum;
|
||||
create view vgassum as
|
||||
|
||||
select
|
||||
cast ( strftime('%Y%m' ,zeitpunkt) as INTEGER ) as mon
|
||||
,round ( sum(gasvolumen ),3) * max(gasfaktor) as gasKWhSum
|
||||
,max(gasfaktor) as gasfaktor
|
||||
from vgasroh
|
||||
group by mon
|
||||
;
|
||||
|
||||
select * from vgassum;
|
||||
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- ------------------------------------------------------------------------------
|
||||
|
||||
drop view if exists vstromroh;
|
||||
create view vstromroh as
|
||||
|
||||
SELECT id,zeitpunkt,stromzaehler,wetterinfo
|
||||
, CAST(replace(stromzaehler ,',','.') as float) as stromval,
|
||||
|
||||
lag ( CAST(replace(stromzaehler ,',','.') as float) ,1 ) over (order by id)
|
||||
as vorstromval
|
||||
|
||||
,
|
||||
case when
|
||||
round(
|
||||
( CAST(replace(stromzaehler ,',','.') as float)) - (lag ( CAST(replace(stromzaehler ,',','.') as float),1 ) over (order by id))
|
||||
,3)
|
||||
is null then 0.0
|
||||
else
|
||||
round(
|
||||
( CAST(replace(stromzaehler ,',','.') as float)) - (lag ( CAST(replace(stromzaehler ,',','.') as float),1 ) over (order by id))
|
||||
,3)
|
||||
end
|
||||
as stromverzehr
|
||||
|
||||
, ( julianday(zeitpunkt) - julianday ( ( lag(zeitpunkt,1) over (order by id) ) ) ) * 24.0
|
||||
as zeitspannestd
|
||||
|
||||
,
|
||||
( ( CAST(replace(stromzaehler ,',','.') as float)) - (lag ( CAST(replace(stromzaehler ,',','.') as float),1 ) over (order by id)) )
|
||||
/( ( julianday(zeitpunkt) - julianday ( ( lag(zeitpunkt,1) over (order by id) ) ) ) * 24.0 )
|
||||
* 24.0 as stromverzehr24
|
||||
|
||||
|
||||
|
||||
from eintraege where stromzaehler>0 ;
|
||||
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- ------------------------------------------------------------------------------
|
||||
-- ------------------------------------------------------------------------------
|
||||
|
||||
drop view if exists vstromsum;
|
||||
create view vstromsum as
|
||||
|
||||
select
|
||||
cast ( strftime('%Y%m' ,zeitpunkt) as INTEGER ) as mon
|
||||
|
||||
,round ( sum(stromverzehr ),3) as stromKWhSum
|
||||
|
||||
from vstromroh
|
||||
group by mon
|
||||
;
|
||||
|
||||
select * from vstromsum;
|
||||
Reference in new issue
Block a user