Community Documentation

List site's users ranked by total pageviews their content has received.

Last updated July 25, 2009. Created by esllou on September 10, 2008.
Log in to edit this page.

change "LIMIT 5" to whatever you want. If you want you can add WHERE clauses to ignore certain users, content types or unpublished content but this is your basic query.

SELECT users.name,users.uid, SUM( node_counter.totalcount ) AS 'Total Pageviews'
FROM node
JOIN node_counter ON node.nid = node_counter.nid
JOIN users ON node.uid = users.uid
GROUP BY node.uid
ORDER BY `Total Pageviews` DESC LIMIT 5

About this page

Drupal version
Drupal 5.x, Drupal 6.x

Reference

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.