Here is the original query
select ae.kronos_id, ae.first_name, ae.last_name, MAX(wc.start_time, DATE) as max_start_time
from {{qry_Active_Employees.data}} as ae INNER JOIN {{qry_Whos_Clocked_In.data}} as wc
ON ae.kronos_id = wc.account_id
GROUP by ae.kronos_id, ae.first_name, ae.last_name
order by ae.kronos_id
It returns the correct wc.start_time value when there is only one start_time. If there are multiple start_time(s), it return "undefined".
Assuming the problem was with the start_time being a string, I tried the following.
MAX(CAST(ae.start_time) as DATETIME) which returns "undefined" for any multiple start_time(s).
MAX(CONVERT(ae.start_time, DATETIME)) which returns no rows at all.
Thanks