need help with subquery in select
I want to pull from a table both the weight and height, they are in same table with a name field of either weight or height and a value field.
I'm trying this, but the subquery returns more than one value:
select b.pat_ext_id,
a.vital_result as height,
(select d.vital_result from MRVL99 d where D.PTID = b.ptid and d.vital_name = 'Weight') as weight
from MRVL99 a,
MRPA99 b
where
a.PTID = B.PTID
and a.vital_name = 'Height'
order by b.pat_ext_id
Any ideas are greatly appreciated. I'm also afraid that this only gives me results if a person has both a height and a weight in the table.