MIT-LCP / eicu-code

Code and website related to the eICU Collaborative Research Database
https://eicu-crd.mit.edu
MIT License
320 stars 219 forks source link

age #134

Closed Zheng7AI310 closed 4 years ago

Zheng7AI310 commented 4 years ago

There is a Column of age in icustay_detial. There is a string variable of'>89' in age.,what caused me to have trouble extracting adult patients. SQL statement 'where age>16 'will report an error. May I ask how to solve this.

alistairewj commented 4 years ago

You can handle it with two conditions:

WHERE (age = '> 89' OR CAST(age AS NUMERIC) > 16)

Zheng7AI310 commented 4 years ago

sorry. The code didnot matter.   Error results:nvalid type numeric input syntax: ""   

------------------ Original message ------------------ From: "Alistair Johnson"; Sendtime: Monday, Jun 8, 2020 9:24 PM To: "MIT-LCP/eicu-code"; Cc: "郑瑞"1499975603@qq.com; "Author"; Subject: Re: [MIT-LCP/eicu-code] age (#134)

You can handle it with two conditions:

WHERE (age = '> 89' OR CAST(age AS NUMERIC) > 16)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

alistairewj commented 4 years ago

Yeah I think instead you'll have to make an in-line view:

WITH pt_age AS
(
SELECT patientunitstayid, age,
       CASE WHEN age = '> 89' THEN 89
       WHEN TRIM(age) = '' THEN NULL
       ELSE CAST(age AS NUMERIC)
       END AS age_numeric
FROM `physionet-data.eicu_crd.patient` pt
)
...
Zheng7AI310 commented 4 years ago

thanks!

------------------ Original message ------------------ From: "Alistair Johnson"; Sendtime: Monday, Jun 8, 2020 10:36 PM To: "MIT-LCP/eicu-code"; Cc: "郑瑞"1499975603@qq.com; "Author"; Subject: Re: [MIT-LCP/eicu-code] age (#134)

Yeah I think instead you'll have to make an in-line view: WITH pt_age AS ( SELECT patientunitstayid, age, CASE WHEN age = '> 89' THEN 89 WHEN TRIM(age) = '' THEN NULL ELSE CAST(age AS NUMERIC) END AS age_numeric FROM physionet-data.eicu_crd.patient pt ) ...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.