Have you considered loading the two tables to a database and running
DBI with the following SQL embedded? I used the test data for two tables one containing Jobs and one containing Users with headers for the tables being Start, Stop, and User or Job
SELECT
Jobs.Job,
Users.User,
Count(Users.User) AS CountOfUser
FROM Jobs LEFT JOIN Users
ON (
(
Jobs.Start <= Users.Start and
Jobs.Stop >= Users.Start
) or
(
Jobs.Start <= Users.Stop and
Jobs.Stop >= Users.Stop
) or
(
Users.Start <= Jobs.Start and
Users.Stop >= Jobs.Start
) or
(
Users.Start <= Jobs.Stop and
Users.Stop >= Jobs.Stop )
)
GROUP BY Jobs.Job, Users.User
HAVING Count(Users.User) = 1;
I haven't put this into
DBI syntax I just drummed it up quickly in Access but the SELECT .. FROM .. syntax should copy over. My results on your test data are.
Job User CountOfUser
job_id1 uname1 1
job_id2 uname2 1
job_id3 uname2 1
job_id4 uname2 1
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.