Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2011
    Posts
    12

    Unanswered: How to create a VIEW selecting data from multiple tables for a ranged time interval

    I have the Tables Patient, Doctor, Treatment, Pat_Doc_Treat, and Schedule.

    Patient(patientNumb, SS, name, dateOfBirth, address, dateAdmitted, clinic)
    Doctor(doctorID, name, pagerNumb)
    Treatment(treatmentCode, desciption)
    Pat_Doc_Treat(patientNumb, doctorID, treatmentCode, date, comments)
    Schedule(doctorID, date, clinic, numbOfWorkHours)

    The task is:
    A doctor, including the doctor's ID, name, and number of patients treated by the doctor in the clinic for a given date interval.

    My question is:
    How do you create a VIEW to select certain data from multiple tables for a ranged time interval?

    I tried creating this view:
    Code:
    CREATE VIEW V_Doc AS
    SELECT d.doctor.ID, d.name, count(pdt.*)
    FROM Doctor d, Pat_Doc_Treat pdt
    WHERE d.doctorID=pdt.doctorID AND pdt.treatmentCode AND pdt.date IN(SELECT date FROM Schedule);

    Is it better to write a stored procedure for this or is a view able to fulfill my question?

    Thank you.

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >Is it better to write a stored procedure for this or is a view able to fulfill my question?
    Which metric at what value quantifies better?
    Last edited by anacedent; 10-26-11 at 20:57.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •