in reply to SQL Query for Scheduling

What have you written so far? Did you try something already or is this just a theoretical question (in which case the answers are "Yes, it is to be done in SQL or Perl" and "Through a combination of SELECTs and JOINs with some WHEREs sprinkled in").

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law