select a.patient_id,a.visit_id,c.name,b.bed_no
from VITAL_SIGNS_REC a,PATS_IN_HOSPITAL b,PAT_MASTER_INDEX c
where a.time_point = (select max(time_point) from VITAL_SIGNS_REC where patient_id = b.patient_id and vital_signs = '体温' and b.dept_code = '35') and
a.patient_id = b.patient_id and b.patient_id = c.patient_id and a.vital_signs = '体温' and b.dept_code = '35' order by bed_no asc
1 201579 2 陈少明 16
2 220878 1 姬琳 17
3 220877 1 赵艳丽 18
4 220686 1 王媛媛 19
5 220732 1 郝振杰 20
2.现在需要在原来查询语句之上 增加2个列,但是这2个列需要通过单独查询得出,让后跟原来的数据合并到一起 。
select a.patient_id,a.visit_id, a.vital_signs_values,c.name,b.bed_no,
(select vital_signs_values from (select ROWNUM RECNO,vital_signs_values from (SELECT * FROM VITAL_SIGNS_REC d where d.patient_id=a.patient_id and d.vital_signs='体温' ORDER BY d.time_point desc ) where rownum<=3 order by rownum asc) where RECNO=2) as vital_signs_values2
from VITAL_SIGNS_REC a,PATS_IN_HOSPITAL b,PAT_MASTER_INDEX c
where a.time_point = (select max(time_point) from VITAL_SIGNS_REC where patient_id = b.patient_id and vital_signs = '体温' and b.dept_code = '35') and
a.patient_id = b.patient_id and b.patient_id = c.patient_id and a.vital_signs = '体温' and b.dept_code = '35' order by bed_no asc
问题出在 patient_id = b.patient_id 标示红色的地方 invalid column name ,记得以前在SQL中是可以执行的,现在oracle中不能执行 ,请指教!