title: Oracle/SQL -Sales broken out by Months
body: <p>Hello I have created the following query to pull total order by month for a salesMen. while this gets me the data I need for a single salesmen i need to run this for more than just one. what I would like to accomplish is a query that pull for several different salesmen and is broken out by month and the Months being the Columns names(Columns dynamic to months being pulled). Like below.</p>
  
  <pre><code> SalesMen   -   10-2017     - 11-2017 - 12-2017 - 01/2018
  ------------------------------------------------------------
  Salesmen_1   Month_total(5)    15       300       100
  Salesmen_2       100          948       821       684
  </code></pre>
  
  <p>Current Code:</p>
  
  <pre><code>select (case when region_code in ('123','124') then 'SalesMen_1' else 'N/A' end)SalesMen, to_char(DATE_ENTERED, 'MM-YYYY') as MM_YYYY, Count(ORder_NO) as Month_Total
  from ORDERS 
  where 
  REGEXP_like (ORder_NO, '^W|^E')
  and DATE_ENTERED between ADD_MONTHS(TO_DATE(TO_CHAR(ADD_MONTHS(SYSDATE, 2), 'YYYY') || '-01-01', 'YYYY-MM-DD'), -3) and TO_DATE(TO_CHAR(SYSDATE, 'YYYY-MM')|| '-01', 'YYYY-MM-DD') - 1
  and region_code in ('123','124')
  group by  to_char(DATE_ENTERED, 'MM-YYYY'),(case when region_code in ('123','124') then 'SalesMen_1' else 'N/A' end)
  order by to_char(DATE_ENTERED, 'MM-YYYY') desc
  </code></pre>
  
  <p>Results:
  <a href="https://i.stack.imgur.com/MV6XW.png" rel="nofollow noreferrer">Current Results Example</a></p>