Re: Group by question

2011-01-20 Thread dan
On 2011-1-16 20:22, Jørn Dahl-Stamnes wrote: Hello, I got a table that store information about which photo-albums that a client is viewing. I want to get the N last visited albums and use the query: mysql> select album_id, updated_at, created_at from album_stats order by updated_at desc limit

Re: Group by question

2011-01-17 Thread Luciano Furtado
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 He meant the execution order, please use the agregation function as suggested. On 11-01-17 05:03, Jørn Dahl-Stamnes wrote: > On Monday 17 January 2011 09:53, Steve Meyers wrote: >> On 1/16/11 5:22 AM, Jørn Dahl-Stamnes wrote: >>> mysql> select album_

Re: Group by question

2011-01-17 Thread Jørn Dahl-Stamnes
On Monday 17 January 2011 09:53, Steve Meyers wrote: > On 1/16/11 5:22 AM, Jørn Dahl-Stamnes wrote: > > mysql> select album_id, updated_at, created_at from album_stats group by > > album_id order by updated_at desc limit 8; > > I believe that your problem is that the group by happens before the >

Re: Group by question

2011-01-17 Thread Steve Meyers
On 1/16/11 5:22 AM, Jørn Dahl-Stamnes wrote: mysql> select album_id, updated_at, created_at from album_stats group by album_id order by updated_at desc limit 8; I believe that your problem is that the group by happens before the order by. Since you're grouping, the updated_at column is not

Re: Group by question

2009-01-07 Thread Niteen Acharya
Hello, I think following query would help you For Ascending select cpid,sum(score),team from j group by cpid order by sum(score) For Descending select cpid,sum(score),team from j group by cpid order by sum(score) desc Thanks! 2009/1/7 Phil > A question on grouping I've never been able to sol

Re: Group by question

2009-01-07 Thread Peter Brawley
Phil >is there any way to modify this query so that it would >return the team having the most entries? See "Within-group aggregates" at http://www.artfulsoftware.com/queries.php PB - Phil wrote: A question on grouping I've never been able to solve... create table j (proj char(3), id int

Re: Group By question

2006-08-31 Thread mizioumt
select * from t where emailaddress in (select emailaddress from t group by emailaddress having count(*) > 1) order by emailaddress; Thanks, Michael -Original Message- From: [EMAIL PROTECTED] To: mysql@lists.mysql.com Sent: Wed, 30 Aug 2006 5:17 PM Subject: Group By question I have a tab

Re: Group By question

2006-08-30 Thread Visolve DB TEAM
006 3:02 AM Subject: Re: Group By question Chris, >I would like to query all rows that have more >than one person with the same email address. select id,count(emailaddr) as howmany from tbl t1 join tbl t2 using(emailaddr) group by id having howmany>1; PB

Re: Group By question

2006-08-30 Thread Peter Brawley
Chris, >I would like to query all rows that have more >than one person with the same email address. select id,count(emailaddr) as howmany from tbl t1 join tbl t2 using(emailaddr) group by id having howmany>1; PB - Chris W wrote: I have a table of people with one of the fields being

RE: Group By Question

2004-10-13 Thread Fan, Wellington
Perfect! Thank you. > -Original Message- > From: Harald Fuchs [mailto:[EMAIL PROTECTED] > Subject: Re: Group By Question > SELECT category_fk, >sum(case status when 1 then 1 else 0 end) AS 'status=1', >sum(case status when 2 then 1 else 0 end)

Re: Group By Question

2004-10-13 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "Fan, Wellington" <[EMAIL PROTECTED]> writes: > Hello Listfolk, > I have a table with a 'category_fk' column and a 'status' column. 'Status' > has but a tiny handful of known values, kinda like an enum. > I'd like to form a query that would give me results like:

Re: GROUP BY question

2004-02-11 Thread Roger Baklund
* Bengt Lindholm > I have a table where I need to group the content on a timestamp. Any > record that is less than say 5 minutes from any other record needs to > be grouped with that other record. > > ID timestamp > 1 2004-02-02 12:00:00 > 2 2004-02-02 12:00:05 > 3 2004-02-02 12:05:20

Re: GROUP BY question

2004-02-10 Thread Jochem van Dieten
Bengt Lindholm wrote: In your example they would all be in the same group. You could say the group delimiter is any gap between records that is 5 minutes or more. So records would be in the same group even if the total timespan for the group is more than 5 minutes, but all gaps between individua

Re: GROUP BY question

2004-02-10 Thread Bengt Lindholm
On 2004-02-10, at 16.21, Brian Power wrote: I'm not sure if it is possible to do with a group by Say you had 1 2004-02-02 12:00:00 2 2004-02-02 12:00:05 3 2004-02-02 12:00:09 4 2004-02-02 12:00:12 this would require 1,2 and 3 in one group and 2,3,4 in another. My understanding is that you

RE: GROUP BY question

2004-02-10 Thread Brian Power
I'm not sure if it is possible to do with a group by Say you had 1 2004-02-02 12:00:00 2 2004-02-02 12:00:05 3 2004-02-02 12:00:09 4 2004-02-02 12:00:12 this would require 1,2 and 3 in one group and 2,3,4 in another. My understanding is that you cant have the same rec in two groups I thi

Re: GROUP BY Question (p2)

2001-03-30 Thread Bob Hall
Sir, try SELECT g1.name, g1.score, g1.id FROM grades g1, grades g2 WHERE g1.name = g2.name GROUP BY g1.name, g1.score HAVING Max(g1.score) = Max(g2.score); Bob Hall >Q: I have the following table "grades". > >++++ >| name | score |id | >+