Skip to content

Most items $2 · Packs priced separately

pocketshelf

Blog and CMS SQL: Reporting Queries

sql-reporting-queries-for-blog-and-cms.pdfShowing 20 of 78 lines
// posts per month
SELECT date_trunc('month', published_at) AS month, count(*) AS posts
FROM posts
GROUP BY 1
ORDER BY 1;

// Top authors by word_count
SELECT p.display_name, sum(c.word_count) AS total
FROM authors p
JOIN posts c ON c.author_id = p.id
GROUP BY p.id, p.display_name
ORDER BY total DESC
LIMIT 10;

// Share by status
SELECT status, count(*) AS n,
       round(100.0 * count(*) / sum(count(*)) OVER (), 1) AS pct
FROM posts
GROUP BY status
ORDER BY n DESC;

What's inside

  • Blog and CMS SQL: Reporting Queries, preview page 1 with code examples in two columnsPage 1
  • Blog and CMS SQL: Reporting Queries, preview page 2 with code examples in two columnsPage 2
Format
PDF, Markdown, SQL
Contents
12 queries
Version
1.0 · Updated 3 Oct 2026
Licence
Commercial What this means
Checked
Checked before it ships
Files in your download
  • sql-reporting-queries-for-blog-and-cms.pdfPDF · 21 KB
  • sql-reporting-queries-for-blog-and-cms.mdMarkdown · 3 KB
  • sql-reporting-queries-for-blog-and-cms.sqlSQL · 3 KB
  • LICENSE.txtadded to every download

About this item

A compact, printable snippet pack for reporting and analytics queries for a blog and CMS database (authors and posts). Each of the 12 entries has a one-line explanation and a small example you can paste into your editor. The PDF uses a two-column A4 layout designed to sit next to your keyboard, and the same content ships as Markdown so you can search it or drop it into your notes, plus a .sql file with every query. Every SQL example targets PostgreSQL 16.

  • SQL
  • Reporting
  • Blog and CMS
  • PostgreSQL
  • Snippets

You might also grab