Select
A.JBAPName Applicant,
AD.JBATitle JobTitle,
AD.JBAID AdvertID,
E.JBEName EmployeeName,
C.JBCLName ClientName,
CONVERT(CHAR(10),A.JBAPDate,103) AS ApplicationDate,
DATEPART(Month,A.JBAPDate) AS Month,
DATEPART(Year,A.JBAPDate) AS Year,
A.JBAPRefer Referer
From dbo.JBApplication A
inner join dbo.JBAdvert AD on AD.JBAID = A.JBAPAdvertID
inner join dbo.JBEmployee E on E.JBEID = A.JBAPEmployeeID
inner join dbo.JBClient C on C.JBCLID = A.JBAPClientID
Where JBAPSiteID = 30
union
Select
A.JBAPName Applicant,
AD.JBATitle JobTitle,
AD.JBAID AdvertID,
E.JBEName EmployeeName,
C.JBCLName ClientName,
CONVERT(CHAR(10),A.JBAPDate,103) AS ApplicationDate,
DATEPART(Month,A.JBAPDate) AS Month,
DATEPART(Year,A.JBAPDate) AS Year,
A.JBAPRefer Referer
From dbo.JBApplication A
inner join dbo.JBExpiredAdvert AD on AD.JBAID = A.JBAPAdvertID
inner join dbo.JBEmployee E on E.JBEID = A.JBAPEmployeeID
inner join dbo.JBClient C on C.JBCLID = A.JBAPClientID
Order by Year desc, Month desc
|