The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Help with a query?
I'm wondering if anybody would be so kind as to tell me how to do this query. I want to know every member who has posted on a given day sorted in order of number of posts they made that day. So if for example I asked who posted on February 21, 2012, it would show me everybody who posted on that day. And the sorting would be done not by the member's total posts, but by their total posts for that day only. You can basically already do this in the search engine, but you can sort by total posts only.
|
#2
|
|||
|
|||
Try this:
Code:
SELECT userid, username, COUNT(*) as count FROM post WHERE visible=1 AND UNIX_TIMESTAMP('2012-02-22') < dateline AND UNIX_TIMESTAMP('2012-02-23') >= dateline GROUP BY userid ORDER BY count DESC I tried to come up with one that let you just enter the date once, but I'm not that familiar with the mysql functions. On the plus side, this lets you find posts between any two dates. |
#3
|
|||
|
|||
Thanks so much, really appreciate it!
|
#4
|
|||
|
|||
You were on the right track...
The way you have it, the timestamp will contain the time of 00:00:00 so this will give only the date chosen. (between 2012-02-22 00:00:00 and 2012-02-22 11:59:59) Code:
SELECT userid, username, COUNT(*) as count FROM post WHERE visible=1 AND UNIX_TIMESTAMP('2012-02-22') >= dateline AND UNIX_TIMESTAMP('2012-02-23') < dateline GROUP BY userid ORDER BY count DESC |
#5
|
|||
|
|||
Quote:
|
#6
|
|||
|
|||
You're right, a little brain freeze here...
should be this to account for 00:00:00 time.. Code:
SELECT userid, username, COUNT(*) as count FROM post WHERE visible=1 AND dateline >= UNIX_TIMESTAMP('2012-02-22') AND dateline < UNIX_TIMESTAMP('2012-02-23') GROUP BY userid ORDER BY count DESC And dateline will be less than a unix timestamp of '2012-02-23 00:00:00'. |
#7
|
|||
|
|||
Well, that's equivalent to what I had except for where you put the '=', but fair enough, it belongs on the lower date to have the query results match the posts with the given date in the dateline. But it would only affect posts that were posted exactly at midnight (to the second).
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|