September 15, 2011 at 12:46 pm
SELECT HREMP_Adp.EMPLNO, HREMP_Adp.LNAME + ', ' + HREMP_Adp.FNAME+ HREMP_Adp.MI AS [Full Name] FROM HREMP_Adp INNER JOIN HospitalRN ON HREMP_Adp.EMPLNO = HospitalRN.EMPLID WHERE (DATEDIFF(day, HREMP_Adp.HIRE_DATE, HREMP_Adp.TERMDATE) < 0) AND (HREMP_Adp.EMPSTATUS IS NULL) ORDER BY HREMP_Adp.LNAME
fnAME, lNAME, mi
PATRICIAWALSHL
PATRICIAWALSHA
PATRICIAWALSHM
PATRICIAWALSH
tHANKS.
September 15, 2011 at 9:00 pm
Frances L (9/15/2011)
SELECT HREMP_Adp.EMPLNO, HREMP_Adp.LNAME + ', ' + HREMP_Adp.FNAME+ HREMP_Adp.MI AS [Full Name] FROM HREMP_Adp INNER JOIN HospitalRN ON HREMP_Adp.EMPLNO = HospitalRN.EMPLID WHERE (DATEDIFF(day, HREMP_Adp.HIRE_DATE, HREMP_Adp.TERMDATE) < 0) AND (HREMP_Adp.EMPSTATUS IS NULL) ORDER BY HREMP_Adp.LNAMEfnAME, lNAME, mi
PATRICIAWALSHL
PATRICIAWALSHA
PATRICIAWALSHM
PATRICIAWALSH
tHANKS.
I suspect what you mean is that not everyone has a middle initial in this table. The following will fix that. I suggest you read about "ISNULL" in Books Online (the "help" system for SQL Server).
SELECT HREMP_Adp.EMPLNO,
HREMP_Adp.LNAME + ', ' + HREMP_Adp.FNAME + ' ' + ISNULL(HREMP_Adp.MI,'') AS [Full Name]
FROM HREMP_Adp
INNER JOIN HospitalRN ON HREMP_Adp.EMPLNO = HospitalRN.EMPLID
WHERE (DATEDIFF(day, HREMP_Adp.HIRE_DATE, HREMP_Adp.TERMDATE) < 0)
AND (HREMP_Adp.EMPSTATUS IS NULL)
ORDER BY HREMP_Adp.LNAME
;
I also want to point out that the only time your DATEDIFF will work is if a person's TERMDATE is less than their HIREDATE. Not sure you meant to do that or not so I thought I'd bring it to your attention.
--Jeff Moden
Change is inevitable... Change for the better is not.
September 16, 2011 at 6:29 am
Thanks. the hire date and term date is for rehired.
September 18, 2011 at 12:08 pm
Ah... understood. So, are you all set now?
--Jeff Moden
Change is inevitable... Change for the better is not.
September 18, 2011 at 6:12 pm
yes. thanks.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply