HairyMonkeyMan
October 20th, 2006, 08:10 AM
:confused: :confused: :confused:
I'm using Microsoft SQL Server
Hello there :) This one is a bit of a head scratcher. I haven't been able to get this into a query that would finish running before christmas!!
Basically, I've been developing something along the lines of TimeTracker (using asp.net), but with a bit more to it. Members of staff can enter their time and mileage expenses through this system (which is working). Another part of the system is where the project managers come along and approve the time and mileage expenses. I want to provide the project manager with a list of everyone that has entered time or mileage expenses that have not yet been approved - so they can approve, edit or delete the time/mileage records.
Have a look at this ERD:
http://www.mnd.co.uk/mike/pmacs_erd.gif
What I'm interested in here is the Project, Phase, Time, Mileage and Staff tables.
The project manager's staffref is in the Project table under Engineer1.
I have been playing around with the following queries:
--Selecting Staff Records first (this one selects in reasonable time, but I
--don't get all the info needed:
SELECT Staff.FirstName + ' ' + Staff.Surname AS StaffName, Staff.StaffRef
FROM Staff
INNER JOIN Times ON (Times.StaffRef = Staff.StaffRef)
WHERE Times.Approved = '0'
--Selecting Project Records first (this one would get all the info needed,
--but it would take a very long time to run:
SELECT null FROM Project
INNER JOIN [Phase] ON (Project.ProjectNo = Phase.ProjectNo)
INNER JOIN [Times] ON (Times.ProjPhaseID = Phase.ProjPhaseID)
INNER JOIN [Mileage] ON (Mileage.StaffRef = Staff.StaffRef)
WHERE Engineer1 = @Manager AND Times.Approved = '0' OR Mileage.Approved = '0'
If anyone could help with this, that would be excellent. Equally, if anyone just wants to laugh and point - thats cool as well :wave:
I'm using Microsoft SQL Server
Hello there :) This one is a bit of a head scratcher. I haven't been able to get this into a query that would finish running before christmas!!
Basically, I've been developing something along the lines of TimeTracker (using asp.net), but with a bit more to it. Members of staff can enter their time and mileage expenses through this system (which is working). Another part of the system is where the project managers come along and approve the time and mileage expenses. I want to provide the project manager with a list of everyone that has entered time or mileage expenses that have not yet been approved - so they can approve, edit or delete the time/mileage records.
Have a look at this ERD:
http://www.mnd.co.uk/mike/pmacs_erd.gif
What I'm interested in here is the Project, Phase, Time, Mileage and Staff tables.
The project manager's staffref is in the Project table under Engineer1.
I have been playing around with the following queries:
--Selecting Staff Records first (this one selects in reasonable time, but I
--don't get all the info needed:
SELECT Staff.FirstName + ' ' + Staff.Surname AS StaffName, Staff.StaffRef
FROM Staff
INNER JOIN Times ON (Times.StaffRef = Staff.StaffRef)
WHERE Times.Approved = '0'
--Selecting Project Records first (this one would get all the info needed,
--but it would take a very long time to run:
SELECT null FROM Project
INNER JOIN [Phase] ON (Project.ProjectNo = Phase.ProjectNo)
INNER JOIN [Times] ON (Times.ProjPhaseID = Phase.ProjPhaseID)
INNER JOIN [Mileage] ON (Mileage.StaffRef = Staff.StaffRef)
WHERE Engineer1 = @Manager AND Times.Approved = '0' OR Mileage.Approved = '0'
If anyone could help with this, that would be excellent. Equally, if anyone just wants to laugh and point - thats cool as well :wave: