create or replace view grafana_v as
  select concat(di.description, '-', de.description) as description,
         da.ts as ts,
         da.value * di.multiplicator as value,
         de.description as device
    from device_t de,
         dataitem_t di,
         devicedataitem_t ddi,
         collecteddata_t da
    where de.id = ddi.device and
          di.id = ddi.dataitem and
          da.devicedataitem = ddi.id and
          di.multiplicator != 0;


create or replace view grafana_plain_v as
  select concat(di.description, '-', de.description) as description,
         da.ts as ts,
         da.value as value,
         de.description as device
    from device_t de,
         dataitem_t di,
         devicedataitem_t ddi,
         collecteddata_t da
    where de.id = ddi.device and
          di.id = ddi.dataitem and
          da.devicedataitem = ddi.id;


