Saiteja Varma
Saiteja Varma

Reputation: 1

I got few errors in this following query . the errors are says too many values and how do I create tables for those?

INSERT INTO PERSON VALUES(158,'Bouquet','John','M','31/8/2021','11 Vaude Avenue','Armidale',2350,154);
INSERT INTO PERSON VALUES(159,'Bouquet','Maria','F','31/8/2021','11 Vaude Avenue','Armidale',2350,154);

SELECT
     p1.first_name||' '||p1.surname as [Child Name]
    ,p1.birth_date as [DOB]
    ,p1.sex as [Gender]
    ,p3.First_name||' '||p3.surname as [Father's Name]
    ,p2.First_name||' '||p2.surname as [Mother's Name]
    ,p1.next_of_kin
FROM PERSON p1 
LEFT OUTER JOIN PERSON p2 
    ON p1.Next_of_kin = p2.Person_id 
        AND p2.sex = 'F' 
        AND p1.next_of_kin is not NULL 
LEFT OUTER JOIN PERSON P3 
    ON p2.Next_of_kin = p3.Person_id 
        AND p3.sex = 'M' 
        AND p2.next_of_kin IS NOT NULL 
        AND p3.next_of_kin IS NOT NULL;

SELECT 
     patient_id as [Patient ID]
    ,PERSON.First_name||' '||PERSON.Surname as [Patient Name]
    ,admission_date as [Date Admitted]
    ,discharge_date as [Date Discharged]
    ,avg(observ_value) as [Average Temperature]
    ,WARD.Daily_charge * (discharge_date-admission_date) as [Expenses] 
FROM ADMISSION, PERSON, OBSERVATION, WARD
WHERE discharge_date is not NULL 
AND PERSON.Person_id = ADMISSION.Patient_id 
AND OBSERVATION.Observ_type = 'Temp' 
AND WARD.Ward_code = ADMISSION.ward_code 
AND OBSERVATION.Admission_id = ADMISSION.admission_id 
AND ADMISSION.admission_id not IN
(
    SELECT admission_id 
    FROM OPERATION
)
GROUP by OBSERVATION.Admission_id;

SELECT
     STAFF.person_id as [STAFF ID]
    ,first_name||' '||surname as [NAME]
    ,start_date as [DATE JOINED]
    ,(resign_date-start_date) AS [NUMBER OF YEARS SERVED] 
FROM STAFF, PERSON
WHERE PERSON.Person_id = STAFF.Person_id 
AND (resign_date-start_date) = (
    SELECT 
        MAX(resign_date-start_date) 
    FROM STAFF 
    WHERE resign_date is not NULL
)

I've tried to replace the keyword FROM and and the other error says it has too many values in select statement. the errors are says too many values and how do I create tables for those? I do not know how to create tables precisely

Upvotes: 0

Views: 28

Answers (0)

Related Questions