|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Select largest JobID
I am trying to select job duties that are listed under each employee's job description. The only problem is that an employee may have more than one job ID to associate their duties with. I'm trying to grab the max JobID number as I know that that will be the most current. The following SQL is working, but it is still pulling in all of the JobID numbers, not just the MAX JobID. Any help would be much appreciated.
SELECT D.JobID, D.Duties FROM Emp_Users U, Emp_UserJob J, Emp_JobDuties D WHERE U.UserID = MMColParam AND U.UserID = J.UserID AND J.JobID = D.JobID; (SELECT MAX (D.JobID) FROM Emp_Users U, Emp_JobDuties D, Emp_UserJob J WHERE U.UserID = MMColParam AND U.UserID = J.UserID AND J.JobID = D.JobID) |
|
#2
|
||||
|
||||
|
try something like this
Code:
SELECT C.JobID, C.Duties
FROM Emp_Users As A
INNER JOIN Emp_UserJob As B On (A.UserID = B.UserID)
INNER JOIN Emp_JobDuties C On (B.JobID = C.JobID)
WHERE B.JobID =
( SELECT MAX (JobID)
FROM Emp_Users
WHERE UserID = MMColParam
)
AND A.UserID = MMColParam
AND A.UserID = B.UserID
|
|
#3
|
||||
|
||||
|
Thanks a million!
I just had to change one little thing and that worked like a charm. Thank you so much, and thank you for letting me use your service.
Quote:
|
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Select largest JobID |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|