-2
は私がCASTを使用する必要があると考えている時間が、これは最初の「」このような一つだけ
SELECT a.Patient_Number, a.Appt_DateTime, a.Appt_Resource_Descr, a.Appt_Type_Descr, a.Appt_Status, a.Appt_Sched_Department_Descr, p.Patient_Name
FROM vwGenPatApptInfo a
JOIN vwGenPatInfo p
WHERE CAST(a.Patient_Number as VARCHAR(30)) + CAST(a.Appt_DateTime as VARCHAR(30)) in (
select CAST(a.Patient_Number as VARCHAR(30)) + CAST(MIN(a.Appt_DateTime) as VARCHAR(30))
from vwGenPatApptInfo a
WHERE a.Appt_Status='A'
AND a.Appt_DateTime>={ts '2017-01-01 02:25:00'}
AND a.Appt_DateTime<{ts '2017-12-31 23:25:01'}
AND a.Appt_Sched_Department_Descr='Mental Health'
group by a.Patient_Number)
ORDER BY a.Patient_Number, a.Appt_DateTime
[各グループの最上位1行を取得]の可能な複製(https://stackoverflow.com/questions/6841605/get-top-1rowrowof-each-group) –