473,403 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Uosing different rates for employees in various stages

Hi to all
I am building a database to track project expenses information. My
database has 4 main tables, Employees, Activity, project info and
rates.

We add a project and track activities on the project. Each employee
will add an activity on a certain date. What I need to do is check the
date the activity was added and then check what the rate is that
employee was paid during that period.

I am thinking in the lines of a vlookup in excel, but can't seem to
find a similiar function in access. I simply want to add an employee
increase/decrease rate in the rates table. Then, when I add an
activity for a date, it should match the activity date with the rate
date, rounding down (as a vlookup does) and use that rate.

Any assistance in this matter would be appreciated. This will save me
hours of check 10 years worth of activity rates.

Kind regards,

Eddie
Nov 13 '05 #1
3 1590
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You'll have to use a subquery to find the Rate in the correct date
range. E.g., say you wanted to find an employee's Rate for the date
Oct. 31, 2002, you'd use a query like this:

SELECT E.EmployeeName, R.Rate
FROM Employees As E INNER JOIN Rates As R
ON E.EmployeeID = R.EmployeeID
WHERE R.EffectiveDate = (SELECT MAX(EffectiveDate)
FROM Rates WHERE EmployeeID = E.EmployeeID
AND EffectiveDate <= #10/31/2002#)
AND EmployeeID = 2566

The subquery gets the last effective date that is on, or before, Oct.
31, 2002. The main query uses this date to get the Rate that was
entered on that date.

The above assumes the Rates table is structured similar to this:

EmployeeID, EffectiveDate, Rate
< number > < date > < currency or double >

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQMYEp4echKqOuFEgEQLd1QCeNOzXxdoYqYnuqdsfDTS2MX CwQcQAoK7C
Pz9nlsAGb4vx8HWdqhagNQy0
=hyxy
-----END PGP SIGNATURE-----

Eddie wrote:
Hi to all
I am building a database to track project expenses information. My
database has 4 main tables, Employees, Activity, project info and
rates.

We add a project and track activities on the project. Each employee
will add an activity on a certain date. What I need to do is check the
date the activity was added and then check what the rate is that
employee was paid during that period.

I am thinking in the lines of a vlookup in excel, but can't seem to
find a similiar function in access. I simply want to add an employee
increase/decrease rate in the rates table. Then, when I add an
activity for a date, it should match the activity date with the rate
date, rounding down (as a vlookup does) and use that rate.

Any assistance in this matter would be appreciated. This will save me
hours of check 10 years worth of activity rates.


Nov 13 '05 #2
Thanks a million! I really appreciate the help on the sub query. This
works fine and all my records are accurate. I can't say that I
understand the statement quite, but this is what it looks like. Could
you explain the section from where the sub query kicks in. That would
be great. Thanks a million again

Regards,

Eddie

SELECT employees.Name, rates.rate, Activity.Activitydate,
Activity.ProjectName, Activity.Hours, [Hours]*[rate] AS [Total
Activity Cost]
FROM (employees RIGHT JOIN Activity ON employees.empid =
Activity.Empid) LEFT JOIN rates ON employees.empid = rates.empid
WHERE (((rates.effectivedate)=(SELECT MAX(EffectiveDate)
FROM Rates WHERE EmpID = Employees.EmpID
AND EffectiveDate <= activity.activitydate)));
Nov 13 '05 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The subquery selects the date that is on, or before, the Activity Date,
for all the Employees. E.g.: You want to find the latest EffectiveDate
that is on, or before, Oct. 14, 2003. If an employee's Effective dates
are like this:

EffectiveDate
6/15/2001
7/1/2002
7/1/2003 <-
8/1/2004

then 7/1/2003 is the date selected as the Max(EffectiveDate). IOW,
7/1/2003 is the highest (MAX) date before 10/14/2003 in that employee's
list of EffectiveDates.

Since there is only one Rate for that employee on that EffectiveDate (or
should be only one Rate) the main query uses the employee's Rate that is
on the EffectiveDate selected by the subquery.

HTH,

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQMfeKIechKqOuFEgEQLmDQCgkCtBVhrWFoXrZEExgPhiOh yyrWAAoInJ
a97YcA7iFoCe5CnJG5PUnsRD
=JHV3
-----END PGP SIGNATURE-----
Eddie wrote:
Thanks a million! I really appreciate the help on the sub query. This
works fine and all my records are accurate. I can't say that I
understand the statement quite, but this is what it looks like. Could
you explain the section from where the sub query kicks in. That would
be great. Thanks a million again

Regards,

Eddie

SELECT employees.Name, rates.rate, Activity.Activitydate,
Activity.ProjectName, Activity.Hours, [Hours]*[rate] AS [Total
Activity Cost]
FROM (employees RIGHT JOIN Activity ON employees.empid =
Activity.Empid) LEFT JOIN rates ON employees.empid = rates.empid
WHERE (((rates.effectivedate)=(SELECT MAX(EffectiveDate)
FROM Rates WHERE EmpID = Employees.EmpID
AND EffectiveDate <= activity.activitydate)));


Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Eddie | last post by:
I have an Access database that tracks project information. The database is very simple, except for 1 small aspect. Some background: 4 Tables - Project information, Employees, activity and pay...
1
by: Zurghew | last post by:
Hello all, I have just created a database (partially) which will bill customers for work done. However I am stuck when it is comes to different rates for different works. REQUIRED: What I...
3
by: michb | last post by:
I need to be able to calculate on a daily basis, both normal and overtime hours for both payroll and job costing. I also then need to calculate the above on a weekly basis, in order to complete...
2
by: Chad Richardson | last post by:
I would like a single SQL to return all employee's total billable compensation for a year. Their billable rates change throughout the year so under the employee table (one), there is a compensation...
3
by: milam | last post by:
Greetings, I would like to use a query result as a column name in another query, I can't seem to get this to work using Subqueries. Is there a good way to do this? Example: Table...
1
by: webcm123 | last post by:
I'm looking for a good method of securing ratings. Cookies lock isn't sufficient. In addition to cookies I would need something else. I'm introducing some ways. -= Storing rates inside seperate...
4
by: kneielj | last post by:
what are the various stages in generating an object file (.o) from a .c file and then moving on to link the .o 's and libs (.a's) to form an executable? the first step would be preprocesing. what...
7
by: Michel Couche | last post by:
Hello, I am working on a project for a potential customer. The project will basically involve an ASP.Net 2.0 application and a database (ideally MS SQL). The customer has already a hosting...
1
by: gareth | last post by:
Hello I am looking for some help with table structure design, i am creating a database which manages data on loft and cavity wall insulation done by various contractors. The database uses look up...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.