If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > How to create a VIEW selecting data from multiple tables for a ranged time interval

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-26-11, 19:40
Plural Plural is offline
Registered User
 
Join Date: Oct 2011
Posts: 12
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.
Reply With Quote
  #2 (permalink)  
Old 10-26-11, 19:50
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,415
>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?
__________________
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.

Last edited by anacedent; 10-26-11 at 19:57.
Reply With Quote
Reply

Tags
database, oracle, view

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On