Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tricky
Message
From
29/10/2007 12:21:56
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Tricky
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01264786
Message ID:
01264786
Views:
53
Hi all

I've inherited a system and have a tricky query.

There is a table of pay rates with effective date ranges. There is also an employment history. An employee can be employed across multiple rate periods or within one or beginning within one and ending within another, etc.

Initially I thought to do a union for each combination. I also thought of one join for each combination. Is it possible to avoid a cross join?

A rate Foreign key in work.dbf wouldn't work - pun intended - because every new rate would have to generate new work records.
Employee.dbf
EmpID   EmpName
1       Emp1
2       Emp2

Work.DBF
WrkPK Wrk_EmpID   dWrkStart   dWrkTerminated
1     1           2007-01-01  
2     2           2007-01-04  2007-01-20

Rates.dbf
RatPK         Ratdaily      dRatStart    dRatEnd
1             11            2006-12-31   2007-01-05
2             12            2007-01-06
So what I'd like to see is:

Query from 2007-01-01 until 2007-10-29
EmpID EmpName Pay
1 Emp1 55 + 3552 = 3607
2 Emp2 22 + 0168 = 0190

Thanks
Next
Reply
Map
View

Click here to load this message in the networking platform