title: How to select latest entry per month, per year and per week?
body: <p>I have a data table <strong>history</strong>. I wanna generate graphs for which i need,</p>
  
  <ol>
  <li>Last entry for each day</li>
  <li>Last entry for each week</li>
  <li>Last entry for each month</li>
  <li>Last entry for each year</li>
  </ol>
  
  <p>to show values on graph based on selected period type.</p>
  
  <p>With the following piece of sql code, I can fetch <code>last entry per day</code>.</p>
  
  <pre><code>SELECT t.created_on,
       t.earned_value,
       t.planned_value,
       t.budgeted_cost
  FROM history t
  JOIN (SELECT MAX(tt.created_on) 'maxtimestamp'
  FROM history tt
  GROUP BY date(tt.created_on)) m ON m.maxtimestamp = t.created_on
  </code></pre>
  
  <p>How can I get the other three results?</p>