{"id":486,"date":"2014-07-16T16:53:58","date_gmt":"2014-07-16T14:53:58","guid":{"rendered":"http:\/\/www.rocworks.at\/wordpress\/?p=486"},"modified":"2014-07-16T16:53:58","modified_gmt":"2014-07-16T14:53:58","slug":"downtime-query-wincc-oa-with-rdb-manager","status":"publish","type":"post","link":"https:\/\/www.rocworks.at\/wordpress\/?p=486","title":{"rendered":"Downtime Query WinCC OA with RDB-Manager&#8230;"},"content":{"rendered":"<p>Example how to query the downtime of a device which has an alert configuration on the state of the machine (state 0\/1):<\/p>\n<p><code>select element_name, sum(downtime) downtime from (<br \/>\nselect e.element_name,<br \/>\n       h.ts,<br \/>\n       h.VALUE_NUMBER,<br \/>\n       h.direction,<br \/>\n       case<br \/>\n         when h.DIRECTION = 0 then<br \/>\n          CAST((h.ts + 0) - ((lag(h.ts, 1, h.ts) OVER(ORDER BY ts)) + 0) AS FLOAT)*24*60*60<br \/>\n         else<br \/>\n          null<br \/>\n       end as downtime<br \/>\n  from elements e<br \/>\n  join alerthistory h<br \/>\n    on e.element_id = h.ELEMENT_ID<br \/>\n where e.element_name like<br \/>\n       'Device_%.Status'<br \/>\n   and ts between to_date('01.07.2014','DD.MM.YYYY') and to_date('31.07.2014','DD.MM.YYYY')<br \/>\n) group by element_name<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Example how to query the downtime of a device which has an alert configuration on the state of the machine (state 0\/1): select element_name, sum(downtime) downtime from ( select e.element_name, h.ts, h.VALUE_NUMBER, h.direction, case when h.DIRECTION = 0 then CAST((h.ts &hellip; <a href=\"https:\/\/www.rocworks.at\/wordpress\/?p=486\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-486","post","type-post","status-publish","format-standard","hentry","category-allgemein"],"_links":{"self":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=486"}],"version-history":[{"count":1,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/486\/revisions"}],"predecessor-version":[{"id":487,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/486\/revisions\/487"}],"wp:attachment":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}