1-如何显示那里的医生从来没有做过检查doctorid,doctorname,doctorphone和doctorbirthyear(从doctorbirthdate的一年)。
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-如何显示medicid,medicinename和medicineprice(含USD)药物不是由doctorid ='dc001'销售的。
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-如何显示patientid,patientname和patientbirthyear(从patientbirthdate的一年)该病人被医生比病人年轻化服务。
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;
希望这会有所帮助。
分享您为解决上述问题而采取的一些代码/查询工作,它不仅仅是发布问题 – akhilsk