1- 我如何显示医生从未做过检查的医生编号、医生姓名、医生电话和医生出生年份(从医生出生日期开始)。
select doctorid, doctorname, doctorphone , year(DoctorBirthDate) as doctorbirthyear
from msdoctor
where doctorid not in (select doctorid from transactionheader) ;
2- 如何显示一年中第 12 个月出售的药品的药名、药名和药价。
select medicinename, medicinetypename, medicineprice
from MsMedicineType mt, MsMedicine m , TransactionDetail td, TransactionHeader th
where mt.MedicineTypeID=m.MedicineTypeID and m.MedicineID=td.MedicineID and td.TransactionID=th.TransactionID and month(th.TransactionDate) = 12;
3- 我如何在医生 ID = 'dc001' 不出售的药物的情况下显示药物 ID、药物名称和药物价格(以美元计)。
select medicinename, medicinetypename, concat(medicineprice,'$') as medicineprice
from MsMedicineType mt, MsMedicine m , TransactionDetail td, TransactionHeader th
where mt.MedicineTypeID=m.MedicineTypeID and m.MedicineID=td.MedicineID and td.TransactionID=th.TransactionID and th.DoctorID!='dc001';
4- 如何在比患者年轻的医生为患者服务的地方显示患者 ID、患者姓名和患者出生年份(从患者出生日期开始)。
select p.patientid, p.patientname, year(PatientBirthDate) as patientbirthyear
from TransactionHeader th , msdoctor m, mspatient p
where th.DoctorID=m.DoctorID and th.PatientID=p.PatientID and PatientBirthDate>DoctorBirthDate;
希望这会有所帮助。