สารบัญ

/*ผู้ป่วยหญิงที่ Diag ด้วยโรคเฉพาะ ชาย */

set @date1 = '2014-10-01',@date2 = '2015-10-01';

SELECT pt.pname,concat(pt.fname,space(1),pt.lname)as 'patient_name'

,pt.sex,o.vstdate,o.vsttime,o.icd10,

(

SELECT name

FROM icd101

WHERE `code` = o.icd10) AS 'diag_name'

FROM ovstdiag o

INNER JOIN patient pt ON pt.hn = o.hn

WHERE pt.sex = 2 AND o.icd10 IN('N40', 'N41', 'N410', 'N411', 'N412', 'N413', 'N418', 'N419', 'N42', 'N420', 'N421', 'N422', 'N423', 'N428', 'N429', 'N43', 'N430', 'N431', 'N432', 'N433', 'N434', 'N44', 'N45', 'N450', 'N459', 'N46', 'N47', 'N48', 'N480', 'N481', 'N482', 'N483', 'N484', 'N485', 'N486', 'N488', 'N489', 'N49', 'N490', 'N491', 'N492', 'N498', 'N499', 'N50', 'N500', 'N501', 'N508', 'N509', 'N51', 'N510', 'N511', 'N512', 'N518', 'b260', 'c60', 'c61', 'c62', 'c63', 'd07', 'd176', 'd290', 'd291', 'd292', 'd293', 'd294', 'd295', 'd296', 'd297', 'd298', 'd400', 'd401', 'd402', 'd403', 'd404', 'd405', 'd406', 'd407', 'd408', 'd409', 'e290', 'e291', 'e292', 'e293', 'e294', 'e295', 'e296', 'e297', 'e298', 'e299', 'e895', 'f524', 'i861', 'l291', 'N40', 'Q53', 'Q530', 'Q531', 'Q532', 'Q539', 'Q54', 'Q540', 'Q541', 'Q542', 'Q543', 'Q544', 'Q548', 'Q549', 'Q55', 'r86', 'S312', 'S313', 'z125'

) AND vstdate between @date1 and @date2;

#======================

ตัวอย่าง

pname patient_name sex vstdate vsttime icd10 diag_name
น.ส. นุชจรี xxx 2 2015-09-07 00:00:02 Z125 Special screening examination for neoplasm of prostate