There is a table: TB
Table structure:
The patient ID, date, drug coding (other fields can be ignored)
I want to find, those patients had one day, at the same time open drug code for A, B, C three kinds of medicine,
Results:
The patient ID date
10002 the 2020-10-29
10002 the 2020-10-30
10002 the 2020-11-04
10003 the 2020-11-01
10003 the 2020-11-02
The 2020-11-03 10004
CodePudding user response:
Select the patient ID, date
From the table
Where drug code in (A, B, C)
Group by the patient ID, date
Having a count (drug code)=3
CodePudding user response: