Sunday, March 2, 2014

# Script JHCIS-MySQL หารายชื่อหญิงตั้งครรภ์กลุ่มเป้าหมายตรวจมะเร็งปากมดลูก ปี 2553-2557 ที่ยังไม่ตรวจ

# Script JHCIS-MySQL หารายชื่อหญิงตั้งครรภ์กลุ่มเป้าหมายตรวจมะเร็งปากมดลูก ปี 2553-2557 ที่ยังไม่ตรวจ
SELECT
person.pid,
person.prename as คำนำ,
person.fname as ชื่อ,
person.lname as นามสกุล,
year(now()) - year(person.birth) as อายุ,
concat(day(person.birth),"/",MONTH(person.birth),"/",year(person.birth)+543) AS `วันเดือนปีเกิด`,
person.sex as เพศ,
person.hnomoi as บ้านเลขที่,
person.mumoi as หมู่ที่
FROM
person
LEFT JOIN persondeath ON person.pid = persondeath.pid
WHERE
persondeath.pid IS NULL AND
person.birth between '1954-01-01' and '1984-12-31' and
person.sex = 2 and
person.mumoi <> 0 AND
NOT person.pid IN (SELECT distinct visitlabcancer.pid FROM visitlabcancer WHERE visitlabcancer.typecancer = 2 AND visitlabcancer.datecheck BETWEEN '2009-10-01' and '2014-03-31')
ORDER BY หมู่ที่

No comments:

Post a Comment