title: Is there a way to group timestamp data by 30 day intervals starting from the min(date) and add them as columns
body: <p>I am trying to use the min() value of a timestamp as a starting point and then group data by 30 day intervals in order to get a count of occurrences for each unique value within the timestamp date range as columns </p>
  
  <p>i have two tables that i am joining together to get a count. Table 1 (page_creation) has  2 columns labeled link and dt_crtd. Table 2(page visits) has 2 other columns labeled url and date. the tables are being joined by joining table1.link = table2.pagevisits. </p>
  
  <p>After the join i get a table similar to this:</p>
  
  <pre><code>+-------------------+------------------------+
  | url               |     date               |
  +-------------------+------------------------+
  | www.google.com    | 2018-01-01 00:00:00'   |
  | www.google.com    | 2018-01-02 00:00:00'   |
  | www.google.com    | 2018-02-01 00:00:00'   |
  | www.google.com    | 2018-02-05 00:00:00'   |
  | www.google.com    | 2018-03-04 00:00:00'   |
  | www.facebook.com  | 2014-01-05 00:00:00'   |
  | www.facebook.com  | 2014-01-07 00:00:00'   |
  | www.facebook.com  | 2014-04-02 00:00:00'   |
  | www.facebook.com  | 2014-04-10 00:00:00'   |
  | www.facebook.com  | 2014-04-11 00:00:00'   |
  | www.facebook.com  | 2014-05-01 00:00:00'   |
  | www.twitter.com   | 2016-02-01 00:00:00'   |
  | www.twitter.com   | 2016-03-04 00:00:00'   |
  +---------------------+----------------------+
  </code></pre>
  
  <p>what i am trying to get is results that pull this : </p>
  
  <pre><code>+-------------------+------------------------+------------+------------+-------------+
  | url               | MIN_Date               | Interval 1  | Interval 2|  Interval 3 |
  +-------------------+------------------------+-------------+-----------+-------------+
  | www.google.com    | 2018-01-01 00:00:00'   |  2          |  2        |  1      
  | www.facebook.com  | 2014-01-05 00:00:00'   |  2          |  0        |  1
  | www.twitter.com   | 2016-02-01 00:00:00'   |  1          |  1        |  0    
  +---------------------+----------------------+-------------+-----------+-------------+
  </code></pre>
  
  <p>So the 30 day intervals begin from the min(date) as shown in Interval 1 and are counted every 30 days.</p>
  
  <p>Ive looked at other questions such as :</p>
  
  <p><a href="https://stackoverflow.com/questions/14379337/group-rows-by-7-days-interval-starting-from-a-certain-date">Group rows by 7 days interval starting from a certain date</a></p>
  
  <p><a href="https://stackoverflow.com/questions/42331773/mysql-query-to-select-min-datetime-grouped-by-30-day-intervals">MySQL query to select min datetime grouped by 30 day intervals</a></p>
  
  <p>However it did not seem to answer my specific problem. </p>
  
  <p>Ive also looked into pivot syntax but noticed it is only supported for certain DBMS. </p>
  
  <p>Any help would be greatly appreciated. </p>
  
  <p>Thank you.</p>