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