dimanche 27 mars 2016

SQLite Query Help needed for beginner

I am a student with SQLite and this is the first time I have used it. I have been banging my head trying to come up with a query and I am begging for help. Here is my schema first... CREATE TABLE Doctor ( DoctorID INTEGER NOT NULL, DoctorName TEXT NOT NULL, MedLicenseNumber INTEGER NOT NULL, Phone TEXT NOT NULL ) CREATE TABLE Medication ( MedicationID INTEGER NOT NULL, BrandName TEXT NOT NULL, GenericName TEXT NOT NULL ) CREATE TABLE "Patient" ( PatientID INTEGER NOT NULL, PatientName TEXT NOT NULL, DateOfBirth INTEGER NOT NULL ) CREATE TABLE Prescription ( PrescriptionID INTEGER NOT NULL, Date TEXT NOT NULL, PatientID INTEGER NOT NULL, DoctorID INTEGER NOT NULL, MedicationID INTEGER NOT NULL )

I need a query that will show a report with the patient name,dob,med brand name,and prescribing doc name sorted by most recent date.

I have used this buyt I get 250 lines on the report which isnt right since there are only 15 prescriptions.. Select Patient.PatientName,Patient.DateOfBirth,Medication.BrandName,Doctor.DoctorName from Patient,Medication,Doctor

any ideas? I have searched IBM,sqlites site and I cant figure it out.Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire