Re: Order rows before applying GROUP BY / DISTINCT

2004-10-05 Thread Remi Mikalsen
Ok. Thank you for all your help! I will perform some tests to see how to get the best results. Thank you for offering to help with this stage, but I'll try doing it by myself. Remi Mikalsen E-Mail: [EMAIL PROTECTED] URL:http://www.iMikalsen.com On 5 Oct 2004 at 14:11, [EMAIL PROTECTED]

Re: Order rows before applying GROUP BY / DISTINCT

2004-10-05 Thread SGreen
The only way to know for sure is to try both methods and compare performance. I have had excellent response times from my temporary tables (especially since you can add indexes to them). If you would like some help in crafting some test queries, just post the SHOW CREATE TABLE results for the

Re: Order rows before applying GROUP BY / DISTINCT

2004-10-05 Thread Remi Mikalsen
Ok... I've taken a close look at the various options. * The use of a temporary table would solve the problem. However, I am very uncertain of the efficiency of the use of temporary tables the way you suggest. I would need 6 queries to the database, plus creation of a new table based on another

Re: Order rows before applying GROUP BY / DISTINCT

2004-10-05 Thread Remi Mikalsen
This is what it says about the ONLY_FULL_GROUP_BY option... ONLY_FULL_GROUP_BY Don't allow queries that in the GROUP BY part refer to a not selected column. (New in MySQL 4.0.0.) I don't see how this can help me, because in the GROUP BY part I do refer to a selected column. The probl

Re: Order rows before applying GROUP BY / DISTINCT

2004-10-05 Thread Paul DuBois
At 9:14 -0400 10/4/04, [EMAIL PROTECTED] wrote: What you are looking for is the MAX() of the Time column (most recent entry) select user, host, max(time) as time, count(user) as visits from userlog where user!='' group by user, host order by time desc limit 10; The issue you ran into is caused by a

Re: Order rows before applying GROUP BY / DISTINCT

2004-10-05 Thread SGreen
You are correct, there is no predicate you can use to pull the refurl value from the same row that the MAX(entry) value comes from . That will require a second processing stage. Depending on what version of MySQL you are running, you have some options: *store the results of this MAX() query in

Re: Order rows before applying GROUP BY / DISTINCT

2004-10-04 Thread Remi Mikalsen
If you aren't tired of this problem, I have one more question... The last query worked well, except one small detail... SELECT user, refurl, max( entry ) AS most_recent, count( user ) AS visits FROM userlog WHERE user != '' GROUP BY user ORDER BY most_recent DESC LIMIT 10 I am now includi

Re: Order rows before applying GROUP BY / DISTINCT

2004-10-04 Thread SGreen
I would be very surprised if this query fails as you say it does. select user, max(time) as most_recent, count(user) as visits from userlog where user!='' group by user order by most_recent desc limit 10; This represents the last 10 users to sign in, when they signed in last, and many times the

Re: Order rows before applying GROUP BY / DISTINCT

2004-10-04 Thread Remi Mikalsen
Thank you for the answer! However, it doesn't seem to solve my problem. Running the query without modifications repeated users (because of the "group by user, HOST"). I removed the HOST, and ran the query over again. Now it returned unique users, but it still didn't return the LAST login of t

Re: Order rows before applying GROUP BY / DISTINCT

2004-10-04 Thread SGreen
What you are looking for is the MAX() of the Time column (most recent entry) select user, host, max(time) as time, count(user) as visits from userlog where user!='' group by user, host order by time desc limit 10; The issue you ran into is caused by an non-standard SQL extension created by MyS