Jump to content

MySQL Query Help Needed


ViperSBT

Recommended Posts

I have the following query:

SELECT r.club, MIN(r.besttime) as time, c.cname, t.date
FROM racing r
JOIN clubs c ON r.club = c.cnumber
INNER JOIN tournament t ON t.enumber = r.event && t.date >= '$limit' && r.besttime < 99.999
GROUP BY r.club 
HAVING DATEDIFF( MAX( date ) , MIN( t.date ) ) >4
ORDER BY time, c.cname

 

Which generates the following output:

club time cname date

83 0.000 BH 2005-07-08

146 0.000 MRRFB 2006-03-25

179 0.000 PS 2006-09-23

22 0.000 S 2005-04-30

2 14.963 TNG 2005-04-30

239 15.127 IR 2007-05-26

75 15.359 HF 2005-11-12

7 15.403 RD 2005-05-14

6 15.479 RDS 2005-05-14

 

The racing table has an entry for every event that a club has participated in.  I need the results to only show me clubs that have participated in more than one event and at least two of those events are more than 7 days apart from each other.

 

It seems like there should be a way to do this, but I am lucky I have gotten as far as I have... :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.