[SQL] Some insight on the proper SQL would be appreciated

2010-06-08 Thread Aaron Burnett
Greetings, Any help on this would be appreciated. I have a table which is a list of users who entered a contest. They can enter as many times as they want, but only 5 will count. So some users have one entry, some have as many as 15. How could I distill this down further to give me a list that

Re: [SQL] Some insight on the proper SQL would be appreciated

2010-06-08 Thread Aaron Burnett
Mikhail, Thank you very much. This seems to have worked perfectly. On 6/8/10 1:58 PM, "Mikhail V. Puzanov" wrote: > Hi, > > Something very straightforward looks like this, I guess: > > select * from users u > where ( > select count(*) from users u1 > where u1.username = u.username

Re: [SQL] Some insight on the proper SQL would be appreciated

2010-06-08 Thread Aaron Burnett
ver > > SELECT a.username,a.firstname,a.lastname,a.signedup > FROM t_YourTable a > JOIN t_YourTable b > ON a.username = b.username > AND a.firstname = b.firstname > AND a.lastname = b.lastname > AND a.signedup >= b.signedup > GROUP BY a.username,a.firstname,a.lastname,a.s

[SQL] Drawing a blank on some SQL

2011-02-11 Thread Aaron Burnett
Hi, I'm just drawing a blank entirely today and would appreciate some help on this. The long and short; there are 12 distinct activities that need to be queried on a weekly basis: SELECT count(activity_id), activity_id FROM foo_activity WHERE created >= '01/01/2011' and created < '01/08/2011'

Re: [SQL] Drawing a blank on some SQL

2011-02-11 Thread Aaron Burnett
Thank you all very much for your help. The suggestion from Osvaldo below was the best for my situation (not having any soret of xref table to join)... Best Regards, Aaron On 2/11/11 1:09 PM, "Osvaldo Kussama" wrote: 2011/2/11, Aaron Burnett : > > Hi, > > I'm ju