;WITH MyCte(EType,EventDate,EName,EStatus) AS
(
SELECT 'Exam' AS Expr1, E.DateOfExam, E.ExamName,tbl_ExamAttendence.status
FROM tbl_ExamCreation AS E INNER JOIN
tbl_ExamAttendence ON E.Exam_ID = tbl_ExamAttendence.Exam_ID
WHERE (tbl_ExamAttendence.StudentID = 1044)
UNION ALL
SELECT 'Lecture' AS Expr1, LS.StartDateTime, tbl_Lectures.LectureName,tbl_LectureAttendence.status
FROM tbl_LectureScheduling AS LS INNER JOIN
tbl_LectureAttendence ON LS.LectureScheduleID = tbl_LectureAttendence.LectureScheduleID INNER JOIN
tbl_Lectures ON LS.LectureID = tbl_Lectures.LectureID
WHERE (tbl_LectureAttendence.StudentID = 1044)
)
SELECT TOP 5 EType,EventDate,EName,EStatus FROM MyCte ORDER BY EventDate DESC