Skip to content

Instantly share code, notes, and snippets.

@yibudak
Created April 6, 2022 17:27
Show Gist options
  • Save yibudak/cf2a3006c10de070e1ec520207e15355 to your computer and use it in GitHub Desktop.
Save yibudak/cf2a3006c10de070e1ec520207e15355 to your computer and use it in GitHub Desktop.
Get Last 30 Days Records Count Grouped in MySQL
SELECT DATE_FORMAT(DATE, '%m.%d.%Y') AS date, count(*) AS count
FROM table
WHERE DATE BETWEEN NOW() - INTERVAL 30 DAY AND NOW()
GROUP BY date
ORDER BY date ASC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment