I am done with the SQL CUMULATIVE PROJECT Analyzing Heart Disease. But question 11 makes me wondering:
This is my solution:
with patient_data as(
with patient as (
select * from active_patients
union
select * from inactive_patients)
select * from patient
inner join panels
on patient.ID=panels.patient_ID)
select Name, Round(LDL), Address, Phone
from
patient_data,
(select Borderline_High from recommended_values where Lipid="LDL") rv
where LDL>rv.Borderline_High
order by LDL desc;
It works fine: Perhaps it is not the most elegant one
But my question regards the last lines. Originally I tried to write:
from patient_data
where LDL>(select Borderline_High from recommended_values where Lipid="LDL")
But though the query in the brackets is itself correct the whole get “shot down”
Why?