CREATE VIEW fist_day_glucose AS ( SELECT subject_id, stay_id, charttime, glucose FROM ( SELECT ie.subject_id, ie.stay_id, le.charttime, le.glucose, RANK ( ) OVER ( PARTITION BY ie.stay_id ORDER BY le.charttime ) AS ranking FROM mimiciv_icu.icustays ie INNER JOIN mimiciv_derived.chemistry le ON le.subject_id = ie.subject_id AND le.charttime >= ie.intime AND le.charttime <= DATETIME_ADD ( ie.intime, INTERVAL '1' DAY ) WHERE le.glucose IS NOT NULL ORDER BY ie.subject_id ASC, ie.stay_id ASC ) fist_day_glucose WHERE ranking = 1 )
时间: 2024-03-31 07:34:01 浏览: 111
fist31.rar_cast shadow_cpp31.com
这是一个 SQL 查询语句,它创建了一个名为 "fist_day_glucose" 的视图。视图中包含了每个 ICU 患者在其入住第一天内血糖检测结果。具体来说,它从 "mimiciv_icu.icustays" 和 "mimiciv_derived.chemistry" 表中选择了患者 ID,入住 ID,检测时间和血糖值。使用了 RANK() 函数对每个入住 ID 按照检测时间进行了排序,并筛选出排名为第一的血糖检测结果。在视图中,每个患者只会有一条血糖检测结果。
阅读全文