vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   MySQL Query to get "Top 25 Posters in last 3 months" (https://vborg.vbsupport.ru/showthread.php?t=169070)

russellmd 01-29-2008 02:23 PM

MySQL Query to get "Top 25 Posters in last 3 months"
 
Hi All,

I'm interested to run a query that will give me the First/Last Name, email address and # of posts for the top 25 posters in the last 90 days - can anyone give me a quick MySQL query that will get me this data that I can run whenever I want?

I am a PgSQL guy, and I never run queries against MySQL.

Any assistance would be wonderful...

Mitch

lyndonb 01-29-2008 06:40 PM

something like:

select u.username, count(p.id) from
user u,
posts p
where p.postdate > (unix_timestamp()-(3*31*24*60*60)) and p.userid = u.userid
group by p.id, u.username having count(p.id) = max(p.id)

note the (3*31*24*60*60) will give the seconds for 3 * 31 days, so the 3 months is not exact.

That may be something like, but the syntax may need a tweak...

Eikinskjaldi 01-29-2008 10:57 PM

SELECT u.*, count(*) as 'total' from user u
JOIN post p USING (userid)
WHERE to_days(now()) - to_days(from_unixtime(p.dateline)) <= 90
GROUP BY u.userid
ORDER BY total desc
limit 25

This will be a relatively server intensive query, I wouldn't run it too often.

russellmd 01-30-2008 05:49 PM

Thanks a bunch! :)


All times are GMT. The time now is 02:11 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01092 seconds
  • Memory Usage 1,706KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete