sql中应为不匹配的输入“as”

2024-06-26 14:07:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我的问题如下

for i in range(0,100000,10000):

    query= """select distinct icustay_id, date_diff('second', timestamp '1970-01-01 
    00:00:00', charttime) as charttime, itemid, case when value = 'None' then '0' when value 
    = 'Ventilator' then '1' when value='Cannula' then '2' when value = 'Nasal Cannula' then 
   '2' when value = 'Face Tent' then '3' when value = 'Aerosol-Cool' then '4' when value = 
   'Trach Mask' then '5' when value = 'Hi Flow Neb' then '6' when value = 'Non-Rebreather' 
   then '7' when value = '' then '8'  when value = 'Venti Mask' then '9' when value = 
   'Medium Conc Mask' then '10' else 'valuenum end' as 'valuenum' 

   from mimiciii.chartevents 

   where icustay_id>="+str(200000+i)+" and icustay_id< " + str(210000+i) + " and value is 
   not null and itemid in (467,470,471,223834,227287,194,224691,226707,226730,581,580,224639,226512,198,228096,211,220045   ,220179,225309,6701,6,227243,224167,51,455, 220181,220052,225312,224322,6702,443,52,456,8368,8441,225310,8555,8440,220210,3337,224422,618,3603,615,220277,646,834,3655,223762,223761,678,220074,113,492,491,8448,116,1372,1366,228368,228177,626,223835,3420,160,727,190,220339,506,505,224700,224686,224684,684,224421,224687,450,448,445,224697,444,224695,535,224696,543,3083,2566,654,3050,681,2311)  order by icustay_id, charttime "

我犯了这样的错误

An error occurred (InvalidRequestException) when calling the StartQueryExecution operation: line 1:556: mismatched input 'as' expecting {'.', '[', 'AT', 'OR', 'AND', 'IN', 'NOT', 'BETWEEN', 'LIKE', 'IS', 'END', '=', NEQ, '<', '<=', '>', '>=', '+', '-', '*', '/', '%', '||'}
unable to rollback

在我看来,可能会有一个简单的修复方法,比如某个地方丢失了什么东西


Tags: andinidforvalueasmaskwhen