Click here to get back home

Problems with grouping and Sort

 HomeNewsGroups | Search | About
 mailing.database.mysql    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Problems with grouping and Sort michael.friis 09-12-2006
Get Chitika Premium
Posted by michael.friis on September 12, 2006, 6:46 am
Please log in for more thread options
Hi group
Im currently trying to make a sorta top10 list of people adding certain
items into my database.
Basicly i have a users table (in one database) and the list of
episodes (in another database)
The list of episodes has a user field which identifies the user who
added the specific episode
so i have tried constructing an SQL query that would count how many
rows each user has made in episodes, group them and order them by the
amount they made. I get an error though and was hoping you guys (and
gals) could help me fix it or maybe do it in a more effective way.

mysql> SELECT database1.db_users.username,
count(database2.episodes.user)
-> FROM database1.db_users, database2.episodes
-> WHERE database1.db_users.user_id = database2.episodes.user
-> GROUP BY database2.episodes.user
-> ORDER BY count(user) DESC;
ERROR 1111 (HY000): Invalid use of group function
mysql>

any ideas?


Posted by strawberry on September 12, 2006, 7:21 am
Please log in for more thread options

michael.friis@gmail.com wrote:
> Hi group
> Im currently trying to make a sorta top10 list of people adding certain
> items into my database.
> Basicly i have a users table (in one database) and the list of
> episodes (in another database)
> The list of episodes has a user field which identifies the user who
> added the specific episode
> so i have tried constructing an SQL query that would count how many
> rows each user has made in episodes, group them and order them by the
> amount they made. I get an error though and was hoping you guys (and
> gals) could help me fix it or maybe do it in a more effective way.
>
> mysql> SELECT database1.db_users.username,
> count(database2.episodes.user)
> -> FROM database1.db_users, database2.episodes
> -> WHERE database1.db_users.user_id = database2.episodes.user
> -> GROUP BY database2.episodes.user
> -> ORDER BY count(user) DESC;
> ERROR 1111 (HY000): Invalid use of group function
> mysql>
>
> any ideas?
untested:

SELECT database1.db_users.username,
count(database2.episodes.user)
FROM database1.db_users, database2.episodes
WHERE database1.db_users.user_id = database2.episodes.user
GROUP BY database1.db_users.username
ORDER BY count(user) DESC;


Posted by michael.friis on September 12, 2006, 7:43 am
Please log in for more thread options

strawberry wrote:
> michael.friis@gmail.com wrote:
> > Hi group
> > Im currently trying to make a sorta top10 list of people adding certain
> > items into my database.
> > Basicly i have a users table (in one database) and the list of
> > episodes (in another database)
> > The list of episodes has a user field which identifies the user who
> > added the specific episode
> > so i have tried constructing an SQL query that would count how many
> > rows each user has made in episodes, group them and order them by the
> > amount they made. I get an error though and was hoping you guys (and
> > gals) could help me fix it or maybe do it in a more effective way.
> >
> > mysql> SELECT database1.db_users.username,
> > count(database2.episodes.user)
> > -> FROM database1.db_users, database2.episodes
> > -> WHERE database1.db_users.user_id = database2.episodes.user
> > -> GROUP BY database2.episodes.user
> > -> ORDER BY count(user) DESC;
> > ERROR 1111 (HY000): Invalid use of group function
> > mysql>
> >
> > any ideas?
> untested:
>
> SELECT database1.db_users.username,
> count(database2.episodes.user)
> FROM database1.db_users, database2.episodes
> WHERE database1.db_users.user_id = database2.episodes.user
> GROUP BY database1.db_users.username
> ORDER BY count(user) DESC;

thx but it still complains about the ERROR 1111 invalid use of the
group function.


Similar ThreadsPosted
Sort, Limit then Sort August 11, 2005, 3:55 pm
Problems with getting the right data ? February 8, 2006, 6:50 am
Problems with SELECT July 18, 2007, 3:11 am
problems accessing dev.mysql.com October 11, 2005, 11:48 am
new instance / installation problems March 1, 2006, 11:55 am
Mysql querie problems March 30, 2006, 2:24 am
Problems connecting to ODBC July 24, 2006, 10:42 pm
getchunk problems using mysql 5.0 September 4, 2006, 11:23 am
mysql Install Problems November 1, 2006, 11:49 am
Append Query Problems January 5, 2007, 12:21 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap