SELECT
A.ID
,A.NameLast
,A.NameFirst
,A.Dept
,A.Code
,B.CodeCnt
,Convert(varchar,Convert(datetime, Occurance),22) As Occ
FROM
Employees A
INNER JOIN (SELECT Code,COUNT(Code) CodeCnt FROM Employees GROUP BY Code) B
ON A.Code = B.Code
WHERE
A.NameLast In ('Jones')
And A.NameFirst In ('Bob')
Order By B.CodeCnt
|