我尝试在https://phekb.org/phenotype/type-2-diabetes-mellitus中使用“原始T2DM病例算法的eMERGE OMOP MS SQL版本”。当我运行代码时,出现此错误:“‘#’处或附近存在语法错误”。问题应该出在这里:
SELECT event_id, person_id, start_date, end_date,
op_start_date, op_end_date, visit_occurrence_id
INTO #qualified_events
FROM
(
select pe.event_id, pe.person_id, pe.start_date, pe.end_date,
pe.op_start_date, pe.op_end_date,
row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal,
pe.visit_occurrence_id
FROM primary_events pe
我尝试制作临时表而不是使用“#”,但错误存在。任何建议都会对我有很大帮助。谢谢。
如果是MySQL,则这样写:
CREATE TEMPORARY TABLE IF NOT EXISTS temp_qualified_events AS (
select pe.event_id, pe.person_id, pe.start_date, pe.end_date,
pe.op_start_date, pe.op_end_date,
row_number() over (partition by pe.person_id order by pe.start_date ASC) as ordinal,
pe.visit_occurrence_id
FROM primary_events pe
);
“#”前缀用于 MS SQL 临时表。