我需要将员工姓名分组在一起。我尝试使用“Order By”,但它不适用于空单元格。
顶部的表格是我当前的表格,我想要底部表格的结果。这是我当前的选择查询。
SELECT
DAYNAME(calendar.DATE) AS DAY,
DATE_FORMAT(calendar.DATE, '%d %b %Y') AS Date,
t2.Department,
t2.Name,
TIME(t2.time_enter) AS 'Time In',
TIME(t2.time_exit) AS 'Time Out'
FROM
calendar
LEFT JOIN
(SELECT
employee_hr_id,
time_enter,
time_exit,
department.NAME As Department,
CONCAT(employee.F_NAME, ' ', employee.L_NAME) As Name
from
entry_log
Inner Join employee ON entry_log.EMPLOYEE_HR_ID = employee.HR_ID
Inner Join department ON employee.DEPARTMENT_ID = department.ID
where
CONCAT(employee.F_NAME, ' ', employee.L_NAME) LIKE @NAME) t2 ON date(t2.time_enter) = calendar.date
where
calendar.DATE >= @TIME_ENTER
AND calendar.DATE <= @TIME_EXIT