1

我有一张表,其中包含医生 ID、患者 ID、访问日期和评论。

doctor_id|Patient_id |date_of_visit | comments
------------------------------------------------
1        |     11    |  12-12-2012  | abcdef
2        |     12    |  12-13-2012  | erewrwq
1        |     13    |  12-12-2012  | dsfsdf
3        |     14    |  8-8-2012    | sdfds  
1        |     15    |  12-12-2012  | wereter

怎样才能找到单日就诊3次的医生?例如,上表的结果应该给出

doctor_id
---------
1

因为他在 2012 年 12 月 12 日访问了 3 次

4

4 回答 4

1
select doctor_id
from your_table
group by doctor_id, date_of_visit
having count(*) = 3
于 2013-10-06T07:42:43.333 回答
0
SELECT count(doctor_id) 
  FROM table_name 
 WHERE doctor_id=1
   and date=12-12-2012
于 2013-10-06T07:49:56.307 回答
0

从医生中选择医生 ID,其中 date_of_visit='12-12-2012' 按医生 ID 分组,计数(医生 ID)>3;

您也可以在这里执行此操作.. 无论您需要什么

于 2013-10-07T11:23:21.540 回答
-1

SELECT doctor_id,count(doctor_id) "多少次医生就诊" FROM doctor WHERE doctor_id=1 and date_of_visit='12-12-2012' group by doctor_id;

你可以任何日期..如果你不需要参观多少天,请告诉我我会给你另一个查询

于 2013-10-07T11:19:18.803 回答