{"id":3284,"date":"2020-02-04T22:28:08","date_gmt":"2020-02-04T21:28:08","guid":{"rendered":"http:\/\/van-maanen.com\/?p=3284"},"modified":"2020-02-04T22:28:08","modified_gmt":"2020-02-04T21:28:08","slug":"running-totals-in-oracle","status":"publish","type":"post","link":"http:\/\/archief.van-maanen.com\/?p=3284","title":{"rendered":"Running totals in Oracle"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Oracle has a nice possibility to calculate running totals. Assume we have a sales system where transactions are stored over time. We would like to know the running total &#8211; what is sold until a certain transaction.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The code to calculate this is:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT  trans_id,to_char(trans_date,'dd-mm-yyyy hh24:mi:ss' ) trans_date ,\nproduct_code ,qty* price amount,\nsum(qty* price) over ( order by trans_id ) runing_total\nfrom supermarket_trans \nwhere trunc(TRANS_DATE)=trunc(sysdate)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">which provides:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"http:\/\/van-maanen.com\/wp-content\/uploads\/2020\/02\/Capture-6-6.png\" alt=\"\" class=\"wp-image-3285\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Oracle has a nice possibility to calculate running totals. Assume we have a sales system where transactions are stored over time. We would like to know the running total &#8211; what is sold until a certain transaction. The code to calculate this is: SELECT trans_id,to_char(trans_date,&#8217;dd-mm-yyyy hh24:mi:ss&#8217; ) trans_date , product_code ,qty* price amount, sum(qty* price) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-3284","post","type-post","status-publish","format-standard","hentry","category-allgemein"],"_links":{"self":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts\/3284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3284"}],"version-history":[{"count":0,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts\/3284\/revisions"}],"wp:attachment":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3284"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}