A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
this week in the
MySql query structure
Joined: Jun 22, 2012
Aug 14, 2012 03:55:52
could any member tell me how could I figure out the next query.
In my DDBB I have a field "numbers of times the user has used the system", country, username, userId and timesAccessed(sessionId). I am tying to figure out the next:
Details on the 10 users who more times have accessed to the system, split out by country.
Select username, userId from Users ORDER BY MAX(count(sessionId)) DESC LIMIT 10 where country="US";
Do you think this query makes any sense?
author & internet detective
Joined: May 26, 2003
Aug 14, 2012 17:28:22
There where clause should be before the order by. Also, if you want to split by country rather than just the one, look at group by or a subquery.
How To Ask Questions The Smart Way
Blogging on Certs:
SCEA Part 1
Part 2 & 3
Core Spring 3
TOGAF part 1
Joined: Oct 21, 2008
Aug 16, 2012 06:48:42
do you want the top 10 users in each country?
or you want to know the country of the top 10 users?
I agree. Here's the link:
subject: MySql query structure
Mail Server - Database Design
Problem with SessionId
Security features in Jboss
java.lang.IllegalArgumentException: Parameter UserName does not exist
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014