vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   query problem (https://vborg.vbsupport.ru/showthread.php?t=56565)

PieAndChips 08-28-2003 10:19 AM

query problem
 
Hi, can someone suggest why this query isnt working?

SELECT thread.threadid, COUNT(post.postid) AS posts
FROM thread
INNER JOIN post ON thread.threadid = post.threadid
WHERE (UNIX_TIMESTAMP()-post.dateline) < 86400
GROUP BY thread.threadid, COUNT(post.postid)
ORDER BY COUNT(post.postid) DESC

when i test it in phpMyAdmin i get an invalid use of group function error.

cheers.

Xenon 08-28-2003 12:38 PM

you can't group by threadid and a COUNT() value the same time..
i also think you cannot group by a count() value at all

PieAndChips 08-28-2003 02:01 PM

after a bit of fiddling about i got it working

SELECT
thread.threadid,
thread.title,
thread.lastposter,
COUNT(post.postid) AS numposts
FROM thread
INNER JOIN post ON thread.threadid = post.threadid
WHERE (UNIX_TIMESTAMP()-post.dateline) < 86400
GROUP BY thread.threadid
ORDER BY numposts DESC LIMIT 10

btw, this will give the 10 most active threads during the past 24 hours. :banana:


All times are GMT. The time now is 11: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.01151 seconds
  • Memory Usage 1,705KB
  • 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
  • (3)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