{"id":8559,"date":"2020-05-12T10:14:00","date_gmt":"2020-05-12T10:14:00","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=8559"},"modified":"2025-08-12T06:09:33","modified_gmt":"2025-08-12T06:09:33","slug":"how-to-calculate-revenue-in-mysql","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/","title":{"rendered":"How to Calculate Revenue in MySQL"},"content":{"rendered":"\n<p>It is important to calculate revenue for every business. Here&#8217;s how to calculate revenue in MySQL. You can use it to calculate daily revenue, month by month revenue, year by year revenue, revenue for last 12 months, for current month and more. We will look at each use case in detail.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#How_to_Calculate_Revenue_in_MySQL\" >How to Calculate Revenue in MySQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#How_to_Calculate_Daily_Revenue_in_MySQL\" >How to Calculate Daily Revenue in MySQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#How_to_Calculate_Month_By_Month_Revenue_in_MySQL\" >How to Calculate Month By Month Revenue in MySQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#How_to_Calculate_Year_By_Year_Revenue_in_MySQL\" >How to Calculate Year By Year Revenue in MySQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#How_to_Calculate_Revenue_for_Last_12_months_in_MySQL\" >How to Calculate Revenue for Last 12 months in MySQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#How_to_Calculate_Revenue_for_Last_3_months_in_MySQL\" >How to Calculate Revenue for Last 3 months in MySQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#How_to_Calculate_Revenue_for_Current_month_in_MySQL\" >How to Calculate Revenue for Current month in MySQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#How_to_Calculate_Revenue_for_Current_Quarter_in_MySQL\" >How to Calculate Revenue for Current Quarter in MySQL<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Calculate_Revenue_in_MySQL\"><\/span>How to Calculate Revenue in MySQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here are the steps to calculate revenue in MySQL.<\/p>\n\n\n\n<p>Let&#8217;s say you have 2 tables <em>products(product_id, product_name, price)<\/em> and <em>orders(order_date,product_id, quantity).&nbsp;<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; create table products(product_id int,product_name varchar(255),price int);\nmysql&gt; insert into products(product_id,product_name,price) \n       values(1,'iPhone 11',400),(2,'Samsung Galaxy A50',250);\n\nmysql&gt; select * from products;\n+------------+--------------------+-------+\n| product_id | product_name       | price |\n+------------+--------------------+-------+\n|          1 | iPhone 11          |   400 |\n|          2 | Samsung Galaxy A50 |   250 |\n+------------+--------------------+-------+\n\n\nmysql&gt; create table orders(order_date date,product_id int,quantity int);\n\nmysql&gt; insert into orders(order_date,product_id,quantity) \n       values('2020-05-01',1,23),('2020-05-01',2,35),\n       ('2020-05-02',1,45),('2020-05-02',2,23),('2020-05-03',1,19),\n       ('2020-05-03',2,15),('2020-05-04',1,34),('2020-05-04',2,56);\n\nmysql&gt; select * from orders;\n+------------+------------+----------+\n| order_date | product_id | quantity |\n+------------+------------+----------+\n| 2020-05-01 |          1 |       23 |\n| 2020-05-01 |          2 |       35 |\n| 2020-05-02 |          1 |       45 |\n| 2020-05-02 |          2 |       23 |\n| 2020-05-03 |          1 |       19 |\n| 2020-05-03 |          2 |       15 |\n| 2020-05-04 |          1 |       34 |\n| 2020-05-04 |          2 |       56 |\n+------------+------------+----------+\n\n<\/pre>\n\n\n\n<p>For our example, revenue per order is basically <em>price * quantity.&nbsp;<\/em>We will look at different use cases to calculate revenue in MySQL<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Calculate_Daily_Revenue_in_MySQL\"><\/span>How to Calculate Daily Revenue in MySQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here&#8217;s the SQL query to calculate daily revenue in MySQL.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select <strong>date<\/strong>(order_date),sum(<strong>price*quantity<\/strong>) \nfrom products,orders \nwhere <strong>products.product_id=orders.product_id<\/strong> \ngroup by date(order_date);\n+------------------+---------------------+\n| date(order_date) | sum(price*quantity) |\n+------------------+---------------------+\n| 2020-05-01       |               17950 |\n| 2020-05-02       |               23750 |\n| 2020-05-03       |               11350 |\n| 2020-05-04       |               27600 |\n+------------------+---------------------+\n<\/pre>\n\n\n\n<p>In the above SQL query, we multiply <em>price<\/em> x <em>quantity<\/em> to calculate revenue per order. Since <em>price<\/em> &amp; <em>quantity<\/em> are in different tables, we join&nbsp;<em>products<\/em> and&nbsp;<em>orders&nbsp;<\/em>tables using the condition <em>product.product_id=orders.product_id<\/em>. Then we GROUP by DATE function to aggregate order revenue and get daily revenue.<\/p>\n\n\n\n<p>After you calculate revenue in MySQL, you can use a&nbsp;<a href=\"http:\/\/ubiq.co\/mysql-charts\">reporting tool<\/a> to plot this data on a bar chart or dashboard and share it with your team. Here&#8217;s an example of a bar chart that shows daily revenue, created using <a href=\"https:\/\/ubiq.co\">Ubiq<\/a>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"675\" height=\"441\" src=\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/05\/daily-revenue-mysql.webp?resize=675%2C441&#038;ssl=1\" alt=\"\" class=\"wp-image-8561\"\/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Calculate_Month_By_Month_Revenue_in_MySQL\"><\/span>How to Calculate Month By Month Revenue in MySQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here&#8217;s the SQL query to calculate total revenue per month in MySQL. You just need to replace DATE function in above query with MONTH function<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select <strong>month<\/strong>(order_date),sum(price*quantity) \nfrom products,orders \nwhere products.product_id=orders.product_id \ngroup by <strong>month<\/strong>(order_date);\n+------------------+---------------------+\n| month(order_date)| sum(price*quantity) |\n+------------------+---------------------+\n|          1       |              127950 |\n|          2       |              223750 |\n|          3       |              311350 |\n|          4       |              427600 |\n+------------------+---------------------+<\/pre>\n\n\n\n<p>The above query will display month numbers with their revenue alongside. If you want to display month names, use <a href=\"https:\/\/www.w3schools.com\/sql\/func_mysql_date_format.asp\" target=\"_blank\" rel=\"noreferrer noopener\">DATE_FORMAT<\/a>&nbsp;function<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select <strong>date_format<\/strong>(order_date,'%b'),sum(price*quantity) \nfrom products,orders \nwhere products.product_id=orders.product_id \ngroup by <strong>date_format<\/strong>(order_date,'%b');\n+------------------+---------------------+\n| month(order_date)| sum(price*quantity) |\n+------------------+---------------------+\n|        Jan       |              127950 |\n|        Feb       |              223750 |\n|        Mar       |              311350 |\n|        Apr       |              427600 |\n+------------------+---------------------+\n\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Calculate_Year_By_Year_Revenue_in_MySQL\"><\/span>How to Calculate Year By Year Revenue in MySQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here&#8217;s the SQL query to calculate annual revenue in MySQL. You just need to replace DATE function in above query with YEAR function<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select <strong>year<\/strong>(order_date),sum(price*quantity) \nfrom products,orders \nwhere products.product_id=orders.product_id \ngroup by <strong>year<\/strong>(order_date);<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Calculate_Revenue_for_Last_12_months_in_MySQL\"><\/span>How to Calculate Revenue for Last 12 months in MySQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here&#8217;s the SQL query to calculate monthly revenue for last 12 months. You can use <a href=\"https:\/\/www.w3resource.com\/mysql\/comparision-functions-and-operators\/interval-function.php\" target=\"_blank\" rel=\"noreferrer noopener\">INTERVAL<\/a> function to calculate revenue in MySQL, for last 12 months.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select month(order_date),sum(price*quantity) \nfrom products,orders \nwhere products.product_id=orders.product_id \nand <strong>order_date &gt; now() - INTERVAL 12 month<\/strong> \ngroup by month(order_date);\n<\/pre>\n\n\n\n<p>In the above query, we filter data that is after a past interval of 12 months.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Calculate_Revenue_for_Last_3_months_in_MySQL\"><\/span>How to Calculate Revenue for Last 3 months in MySQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here&#8217;s the SQL query to calculate monthly revenue for last 3 months. You can use INTERVAL function to calculate revenue in MySQL, for last 3 months.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select month(order_date),sum(price*quantity) \nfrom products,orders \nwhere products.product_id=orders.product_id \nand <strong>order_date &gt; now() - INTERVAL 3 month<\/strong> \ngroup by month(order_date);\n<\/pre>\n\n\n\n<p>In the above query, we filter data that is after a past interval of 3 months.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Calculate_Revenue_for_Current_month_in_MySQL\"><\/span>How to Calculate Revenue for Current month in MySQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here&#8217;s the SQL query to calculate monthly revenue for current month. You can use INTERVAL function to calculate revenue in MySQL, for current month.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select month(order_date),sum(price*quantity) \nfrom products,orders \nwhere products.product_id=orders.product_id \n<strong>and order_date &gt;= (LAST_DAY(NOW()) + INTERVAL 1 DAY - INTERVAL 1 MONTH) <\/strong>\n<strong>and order_date &lt; (LAST_DAY(NOW()) + INTERVAL 1 DAY)<\/strong> \ngroup by month(order_date);\n<\/pre>\n\n\n\n<p>In the above query, we filter data that is after a past interval of current month.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Calculate_Revenue_for_Current_Quarter_in_MySQL\"><\/span>How to Calculate Revenue for Current Quarter in MySQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here&#8217;s the SQL query to calculate monthly revenue for current month. You can use QUARTER function to calculate revenue in MySQL, for current quarter.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select month(order_date),sum(price*quantity) \nfrom products,orders \nwhere products.product_id=orders.product_id \n<strong>and QUARTER(order_date)=QUARTER(now()) \nand YEAR(order_date)=YEAR(now())<\/strong> \ngroup by month(order_date);\n<\/pre>\n\n\n\n<p>In the above query, we filter data where quarter of <em>order_date<\/em> is same as quarter of present date.<\/p>\n\n\n\n<p>Hopefully, the above queries can help you calculate revenue in MySQL. If you want to create charts, dashboards &amp; reports from MySQL database, you can try <a href=\"https:\/\/ubiq.co\">Ubiq<\/a>. We offer a 14-day free trial.<\/p>\n\n\n\n<p>Also read:<br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-get-cumulative-total-users-per-day-in-mysql\/\">How to Get Cumulative Total User Per Day in MySQL<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-duplicate-table-in-mysql\/\">How to Duplicate Table in MySQL<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/copy-table-mysql\/\">How to Copy Table in MySQL<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Revenue calculation is important for every business. Here&#8217;s how to calculate revenue in MySQL for month, year, last 12 months, YTD, QTD and other periods.<\/p>\n","protected":false},"author":1,"featured_media":8562,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[324],"tags":[494],"class_list":["post-8559","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","tag-calculate-revenue"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Calculate Revenue in MySQL - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Revenue calculation is important for every business. Here&#039;s how to calculate revenue in MySQL for month, year, last 12 months, YTD, QTD and other periods.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Calculate Revenue in MySQL - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Revenue calculation is important for every business. Here&#039;s how to calculate revenue in MySQL for month, year, last 12 months, YTD, QTD and other periods.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2020-05-12T10:14:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-12T06:09:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/05\/calculate-revenue-in-mysql.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"730\" \/>\n\t<meta property=\"og:image:height\" content=\"410\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Calculate Revenue in MySQL\",\"datePublished\":\"2020-05-12T10:14:00+00:00\",\"dateModified\":\"2025-08-12T06:09:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/\"},\"wordCount\":571,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/05\/calculate-revenue-in-mysql.webp?fit=730%2C410&ssl=1\",\"keywords\":[\"calculate revenue\"],\"articleSection\":[\"MySQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/\",\"url\":\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/\",\"name\":\"How to Calculate Revenue in MySQL - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/05\/calculate-revenue-in-mysql.webp?fit=730%2C410&ssl=1\",\"datePublished\":\"2020-05-12T10:14:00+00:00\",\"dateModified\":\"2025-08-12T06:09:33+00:00\",\"author\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Revenue calculation is important for every business. Here's how to calculate revenue in MySQL for month, year, last 12 months, YTD, QTD and other periods.\",\"breadcrumb\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/05\/calculate-revenue-in-mysql.webp?fit=730%2C410&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/05\/calculate-revenue-in-mysql.webp?fit=730%2C410&ssl=1\",\"width\":730,\"height\":410,\"caption\":\"calculate revenue in mysql\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ubiq.co\/tech-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Calculate Revenue in MySQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#website\",\"url\":\"https:\/\/ubiq.co\/tech-blog\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/\"],\"url\":\"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Calculate Revenue in MySQL - Ubiq BI","description":"Revenue calculation is important for every business. Here's how to calculate revenue in MySQL for month, year, last 12 months, YTD, QTD and other periods.","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:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/","og_locale":"en_US","og_type":"article","og_title":"How to Calculate Revenue in MySQL - Ubiq BI","og_description":"Revenue calculation is important for every business. Here's how to calculate revenue in MySQL for month, year, last 12 months, YTD, QTD and other periods.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2020-05-12T10:14:00+00:00","article_modified_time":"2025-08-12T06:09:33+00:00","og_image":[{"width":730,"height":410,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/05\/calculate-revenue-in-mysql.webp","type":"image\/webp"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Calculate Revenue in MySQL","datePublished":"2020-05-12T10:14:00+00:00","dateModified":"2025-08-12T06:09:33+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/"},"wordCount":571,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/05\/calculate-revenue-in-mysql.webp?fit=730%2C410&ssl=1","keywords":["calculate revenue"],"articleSection":["MySQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/","name":"How to Calculate Revenue in MySQL - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/05\/calculate-revenue-in-mysql.webp?fit=730%2C410&ssl=1","datePublished":"2020-05-12T10:14:00+00:00","dateModified":"2025-08-12T06:09:33+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Revenue calculation is important for every business. Here's how to calculate revenue in MySQL for month, year, last 12 months, YTD, QTD and other periods.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/05\/calculate-revenue-in-mysql.webp?fit=730%2C410&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/05\/calculate-revenue-in-mysql.webp?fit=730%2C410&ssl=1","width":730,"height":410,"caption":"calculate revenue in mysql"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-calculate-revenue-in-mysql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Calculate Revenue in MySQL"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/05\/calculate-revenue-in-mysql.webp?fit=730%2C410&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-2e3","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8559","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=8559"}],"version-history":[{"count":3,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8559\/revisions"}],"predecessor-version":[{"id":9068,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8559\/revisions\/9068"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/8562"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=8559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=8559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=8559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}