title: How to Sum a single Column based on multi grouping in MySQL
body: <p>I'm having a Two Tables one is Sales and another one is BrandMaster</p>
  
  <p>My Requirement : How to Sum a single Column based on <strong>multi grouping</strong> in MySQL</p>
  
  <p>The Structure and Data of Sales Table:</p>
  
  <pre><code>SNo            BID          Amount
  -----------------------------------
  101             1            200
  102             2            500
  103             5            800
  104             8            250
  105             1            200
  106             2            500
  107             5            800
  108             8            250
  </code></pre>
  
  <p>The Structure and Data of BrandMaster Table:</p>
  
  <pre><code>BID           BrandName          
  -------------------------
  1             Prod#1
  2             Prod#2
  3             Prod#3
  4             Prod#4
  5             Prod#5
  6             Prod#6
  7             Prod#7
  8             Prod#8
  </code></pre>
  
  <p>My Expected Output:</p>
  
  <pre><code>BrandName           SumAmount          
  -------------------------
  Prod#1                  400
  Prod#2 and Prod#3       500
  Prod#4                    0
  Prod#5                    0
  Prod#6 and Prod#8      2100
  Prod#7                    0
  </code></pre>
  
  <p>The Sales Table contains the BrandID 'BID' and the Sales Amount with Sales ID 'SNo'. I need the Sum of Sales Amount for each Product and Multi Product. Kindly assist me.</p>
  
  <p>Reference Post: <a href="https://stackoverflow.com/questions/35729678/how-to-sum-a-single-column-based-on-grouping-in-mysql">How to Sum a single Column based on grouping in MySQL</a></p>