Use MySQL Window Functions and CTEs for WordPress Analytics Queries
MySQL window functions and CTEs for WordPress reports An editorial report often asks questions like “the top three posts of each category” or “the running total of comments per month”. With plain GROUP BY such questions need several queries and PHP loops. Window functions (ROW_NUMBER(), RANK(), SUM() OVER) and common table expressions (WITH) answer them…