{"id":11436,"date":"2020-08-28T11:18:07","date_gmt":"2020-08-28T14:18:07","guid":{"rendered":"http:\/\/kb.elipse.com.br\/en\/?p=11436"},"modified":"2020-08-28T11:18:07","modified_gmt":"2020-08-28T14:18:07","slug":"kb-111510-grouping-data-from-a-query-within-a-time-interval","status":"publish","type":"post","link":"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/","title":{"rendered":"KB-111510: Grouping data from a Query within a time interval."},"content":{"rendered":"<h3 style=\"text-align: justify;\">Question:<\/h3>\n<p style=\"text-align: justify;\">How can I group data from an <a href=\"https:\/\/www.elipse.com.br\/en\/produto\/elipse-e3\/\" target=\"_blank\" rel=\"noopener noreferrer\">Elipse E3<\/a> Query within certain time interval? For example, what can I do when I need the sampling time to show data from every 45 minutes? See the line below:<\/p>\n<p style=\"text-align: justify;\">15:00, 15:45, 16:30, 17:15, etc.<\/p>\n<p>&nbsp;<\/p>\n<h3 style=\"text-align: justify;\">Solution:<\/h3>\n<p>First of all, a <a href=\"https:\/\/kb.elipse.com.br\/en\/category\/english\/elipse-e3-en\/e3query-2\/\" target=\"_blank\" rel=\"noopener noreferrer\">Query<\/a> is the object that helps defining queries in the application&#8217;s Database. Every time an E3Browser or a Report search for data in a DB, you will need to send a command; this command informs which data are necessary for that object. So, whenever an application needs to record or retrieve data from the Database, it will send SQL commands. A Query displays a friendly interface, which allows not only creating queries graphically but also immediately following the generated SQL syntax.<\/p>\n<p style=\"text-align: justify;\"><strong>In order to group data in a Query within a given time interval<\/strong>, you can use an algorithm that generates a rounded up date respecting the 45-minute interval.<\/p>\n<p style=\"text-align: justify;\">By using SQL Server functions, we are able to apply the algorithm as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">SELECT\r\n   DATEADD(MINUTE,(DATEDIFF(MINUTE, 0 , E3TimeStamp)\/45)*45,0) AS E3TimeStamp, \r\n   SUM(Campo1) AS Campo1,\r\n   COUNT(*) AS Total\r\nFROM\r\n   TemperaturasCamara001\r\nGROUP BY\r\n   DATEADD(MINUTE,(DATEDIFF(MINUTE, 0 , E3TimeStamp)\/45)*45,0)\r\n  ORDER BY E3TimeStamp ASC<\/pre>\n<p style=\"text-align: justify;\">According to the image below, you can see that all data were displayed within the desired time interval, which is 45 minutes:<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" class=\"aligncenter wp-image-11426 size-full\" src=\"http:\/\/kb.elipse.com.br\/wp-content\/uploads\/2020\/08\/11396_EN.png\" alt=\"How to group data in a given time interval\" width=\"268\" height=\"138\" \/><\/p>\n<p style=\"text-align: justify;\">Since records are grouped every 45 minutes, the other selected fields must employ an aggregation function; these functions are AVG, COUNT, MAX, MIN, and SUM.<\/p>\n<p style=\"text-align: justify;\">The related article, <a href=\"https:\/\/kb.elipse.com.br\/en\/kb13180-sql-query-returning-values-every-10-minutes\/\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>KB-13180: SQL query returning values every 10 minutes<\/strong><\/a>, illustrates another possible alternative for returning data within a certain time interval.<\/p>\n<p>&nbsp;<\/p>\n<h3>Related articles:<\/h3>\n<hr \/>\n<ul>\n<li><a href=\"https:\/\/kb.elipse.com.br\/en\/kb13180-sql-query-returning-values-every-10-minutes\/\" target=\"_blank\" rel=\"noopener noreferrer\">KB-13180: SQL query returning values every 10 minutes<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Question: How can I group data from an Elipse E3 Query within certain time interval? For example, what can I do when I need the sampling time to show data&hellip;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0},"categories":[743],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>KB-111510: Grouping data from a Query within a time interval.<\/title>\n<meta name=\"description\" content=\"This article shows how to use an algorithm to group data from a Query in Elipse E3 (by Elipse Software) within a given time interval.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"KB-111510: Grouping data from a Query within a time interval.\" \/>\n<meta property=\"og:description\" content=\"This article shows how to use an algorithm to group data from a Query in Elipse E3 (by Elipse Software) within a given time interval.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/\" \/>\n<meta property=\"og:site_name\" content=\"Elipse Knowledgebase\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/elipsesoftware\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-28T14:18:07+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/kb.elipse.com.br\/wp-content\/uploads\/2020\/08\/11396_EN.png\" \/>\n<meta name=\"author\" content=\"D\u00e9lio Damin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"D\u00e9lio Damin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/\"},\"author\":{\"name\":\"D\u00e9lio Damin\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/be597eff34b5f24af940a55332870778\"},\"headline\":\"KB-111510: Grouping data from a Query within a time interval.\",\"datePublished\":\"2020-08-28T14:18:07+00:00\",\"dateModified\":\"2020-08-28T14:18:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/\"},\"wordCount\":260,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\"},\"articleSection\":[\"E3Query\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/\",\"url\":\"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/\",\"name\":\"KB-111510: Grouping data from a Query within a time interval.\",\"isPartOf\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#website\"},\"datePublished\":\"2020-08-28T14:18:07+00:00\",\"dateModified\":\"2020-08-28T14:18:07+00:00\",\"description\":\"This article shows how to use an algorithm to group data from a Query in Elipse E3 (by Elipse Software) within a given time interval.\",\"breadcrumb\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\/\/kb.elipse.com.br\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"KB-111510: Grouping data from a Query within a time interval.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/kb.elipse.com.br\/#website\",\"url\":\"https:\/\/kb.elipse.com.br\/\",\"name\":\"Elipse Knowledgebase\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/kb.elipse.com.br\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\",\"name\":\"Elipse Software\",\"url\":\"https:\/\/kb.elipse.com.br\/\",\"sameAs\":[\"http:\/\/www.facebook.com\/elipsesoftware\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png\",\"contentUrl\":\"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png\",\"width\":161,\"height\":58,\"caption\":\"Elipse Software\"},\"image\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/be597eff34b5f24af940a55332870778\",\"name\":\"D\u00e9lio Damin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/fdf251d36430f8dd22144c3f1bc53376?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/fdf251d36430f8dd22144c3f1bc53376?s=96&d=mm&r=g\",\"caption\":\"D\u00e9lio Damin\"},\"url\":\"https:\/\/kb.elipse.com.br\/en\/author\/delio\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"KB-111510: Grouping data from a Query within a time interval.","description":"This article shows how to use an algorithm to group data from a Query in Elipse E3 (by Elipse Software) within a given time interval.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/","og_locale":"en_US","og_type":"article","og_title":"KB-111510: Grouping data from a Query within a time interval.","og_description":"This article shows how to use an algorithm to group data from a Query in Elipse E3 (by Elipse Software) within a given time interval.","og_url":"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/","og_site_name":"Elipse Knowledgebase","article_publisher":"http:\/\/www.facebook.com\/elipsesoftware","article_published_time":"2020-08-28T14:18:07+00:00","og_image":[{"url":"http:\/\/kb.elipse.com.br\/wp-content\/uploads\/2020\/08\/11396_EN.png"}],"author":"D\u00e9lio Damin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"D\u00e9lio Damin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/#article","isPartOf":{"@id":"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/"},"author":{"name":"D\u00e9lio Damin","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/be597eff34b5f24af940a55332870778"},"headline":"KB-111510: Grouping data from a Query within a time interval.","datePublished":"2020-08-28T14:18:07+00:00","dateModified":"2020-08-28T14:18:07+00:00","mainEntityOfPage":{"@id":"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/"},"wordCount":260,"commentCount":0,"publisher":{"@id":"https:\/\/kb.elipse.com.br\/#organization"},"articleSection":["E3Query"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/","url":"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/","name":"KB-111510: Grouping data from a Query within a time interval.","isPartOf":{"@id":"https:\/\/kb.elipse.com.br\/#website"},"datePublished":"2020-08-28T14:18:07+00:00","dateModified":"2020-08-28T14:18:07+00:00","description":"This article shows how to use an algorithm to group data from a Query in Elipse E3 (by Elipse Software) within a given time interval.","breadcrumb":{"@id":"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/kb.elipse.com.br\/en\/kb-111510-grouping-data-from-a-query-within-a-time-interval\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/kb.elipse.com.br\/en\/"},{"@type":"ListItem","position":2,"name":"KB-111510: Grouping data from a Query within a time interval."}]},{"@type":"WebSite","@id":"https:\/\/kb.elipse.com.br\/#website","url":"https:\/\/kb.elipse.com.br\/","name":"Elipse Knowledgebase","description":"","publisher":{"@id":"https:\/\/kb.elipse.com.br\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kb.elipse.com.br\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/kb.elipse.com.br\/#organization","name":"Elipse Software","url":"https:\/\/kb.elipse.com.br\/","sameAs":["http:\/\/www.facebook.com\/elipsesoftware"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/","url":"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png","contentUrl":"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png","width":161,"height":58,"caption":"Elipse Software"},"image":{"@id":"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/be597eff34b5f24af940a55332870778","name":"D\u00e9lio Damin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/fdf251d36430f8dd22144c3f1bc53376?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fdf251d36430f8dd22144c3f1bc53376?s=96&d=mm&r=g","caption":"D\u00e9lio Damin"},"url":"https:\/\/kb.elipse.com.br\/en\/author\/delio\/"}]}},"_links":{"self":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/11436"}],"collection":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/comments?post=11436"}],"version-history":[{"count":4,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/11436\/revisions"}],"predecessor-version":[{"id":11440,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/11436\/revisions\/11440"}],"wp:attachment":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/media?parent=11436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/categories?post=11436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/tags?post=11436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}