raf35
February 27th, 2005, 10:50 AM
I have created a patient table as follows:
CREATE TABLE PATIENT(
SSN CHAR(9),
FirstName VARCHAR(15),
MiddleName VARCHAR(10),
LastName VARCHAR(15),
Address VARCHAR(20),
DateofBirth DATE,
PCP_Lic_No VARCHAR(6),
PCP_Lic_State CHAR(2),
PRIMARY KEY(SSN),
FOREIGN KEY(PCP_Lic_No) REFERENCES DOCTOR(DOCTOR_Lic_No));
I have few records in patient table and one of the patient's DOB = '03-OCT-38' so now I need to create view of all the patients who are age over 60. I do that by getting the system date and subtracting it from patient dateofbirth and dividing it by 365 then comparing it with 60 as follows:
CREATE VIEW SENIOR_PATIENT
AS SELECT * FROM PATIENT
WHERE (((SELECT SYSDATE FROM SYS.DUAL) - PATIENT.DATEOFBIRTH)/365) > 60;
So if everything works fine then this should have a record of a patient with DOB = '03-OCT-38'. But there is no record in the view. Can someone tell me what am i doing wrong or missing. I appreciate your help.
Thanks,
raf35
CREATE TABLE PATIENT(
SSN CHAR(9),
FirstName VARCHAR(15),
MiddleName VARCHAR(10),
LastName VARCHAR(15),
Address VARCHAR(20),
DateofBirth DATE,
PCP_Lic_No VARCHAR(6),
PCP_Lic_State CHAR(2),
PRIMARY KEY(SSN),
FOREIGN KEY(PCP_Lic_No) REFERENCES DOCTOR(DOCTOR_Lic_No));
I have few records in patient table and one of the patient's DOB = '03-OCT-38' so now I need to create view of all the patients who are age over 60. I do that by getting the system date and subtracting it from patient dateofbirth and dividing it by 365 then comparing it with 60 as follows:
CREATE VIEW SENIOR_PATIENT
AS SELECT * FROM PATIENT
WHERE (((SELECT SYSDATE FROM SYS.DUAL) - PATIENT.DATEOFBIRTH)/365) > 60;
So if everything works fine then this should have a record of a patient with DOB = '03-OCT-38'. But there is no record in the view. Can someone tell me what am i doing wrong or missing. I appreciate your help.
Thanks,
raf35