This is a good as I could do with MySQL 4.1.10
CREATE TEMPORARY TABLE Temp1 select a.ring_event_id, a.event_name, a.ring_id, a.start_time, ADDTIME(a.start_time, time_per_dog * count(b.dog_id)) as end_time, count(b.dog_id) as num_dogs from ring_event a, tda b where a.ring_event_id = b.ring_event_id group by a.ring_event_id; CREATE TEMPORARY TABLE Temp2 select a.ring_event_id, a.event_name, a.ring_id, a.start_time, ADDTIME(a.start_time, time_per_dog * count(b.dog_id)) as end_time, count(b.dog_id) as num_dogs from ring_event a, tda b where a.ring_event_id = b.ring_event_id group by a.ring_event_id; select ring_event_id, person.name, group_concat(skill.skill) as skills from person join skill_entry on person.person_id = skill_entry.person_id join skill on skill_entry.skill_id = skill.skill_id join ring_event where person.person_id not in ( select person.person_id from tda a join dog on a.dog_id = dog.dog_id join person on dog.person_id = person.person_id join Temp1 b on a.ring_event_id = b.ring_event_id join Temp2 c on (b.start_time < c.end_time and b.end_time > c.start_time) where b.ring_event_id = ring_event.ring_event_id ) group by ring_event_id, name order by ring_event_id, name; drop table Temp1; drop table Temp2;
The subselect is getting all people that are busy while ring_event.ring_event_id is in progress. And then the main select gets all the people that aren't busy.
A picture is worth a thousand words, but takes 200K.

In reply to Re: Interesting scheduling application problem. by gam3
in thread Interesting scheduling application problem. by blue_cowdawg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.