【发布时间】:2016-05-11 18:25:51
【问题描述】:
我需要结果看起来像:
PatientID Doctors
Patient1 3
Patient2 2
Patient3 1
预定的桌子是这样的
GPS Table
PatientID DoctorID DATE
Patient1 Doctor1 2016-02-16
Patient1 Doctor1 2016-04-08
Patient1 Doctor2 2016-06-09
Patient2 Doctor3 2017-01-02
Patient2 Doctor6 2016-12-01
Patient3 Doctor1 2016-07-12
还有更多的预订,但我只是以这张桌子为例。 此外,我需要确保如果该人为医生预订了 2 次,则不会计算同一位医生。
我现在的代码是:
select Bookings.PatientID, count(Bookings.DoctorID) as Doctors from Bookings where Bookings.DoctorID;
感谢您的帮助!
【问题讨论】: