พัฒนาการ 9,18,30,42 นับทั้งปีมีกี่คนและพัฒนาการผิดปกติรายด้าน

  scptตรวจสอบความครอบคลุม "ผลคีร์พัฒนาการ" รายเดือน  <<< คลิ๊กจ้า

1.ใช้ scpt หาพัฒนาการ 4 กลุ่มวัย ทั้งปี (นับจาก 2015-10-01 ถึง '2016-09-30'  ตามนี้
...................................................
Select p.pid,ct.titlename,p.fname,p.lname,p.birth,GetAgeymd(p.birth,CURDATE())as age,
p.idcard as idcard,h.hno as hno,Right(h.villcode,2) as village
,case when GetAgemonth(p.birth,'2015-10-01')= '9' then '9'
when GetAgemonth(p.birth,'2015-10-01')= '18' then '18'
when GetAgemonth(p.birth,'2015-10-01')= '30' then '30'
when GetAgemonth(p.birth,'2015-10-01')= '42' then '42' else '' end as'เดือน'
,'2015-10-01'AS'เดือนที่อายุถึง'
from person p
inner join ctitle ct on p.prename = ct.titlecode
inner join house h on p.pcucodeperson = h.pcucode and p.hcode = h.hcode
where p.typelive in ('1','3')and p.pid not in (select persondeath.pid from persondeath)
and RIGHT(h.villcode,2)<> '00' and GetAgemonth(p.birth,'2015-10-01') in ('9','18','30','42')
UNION
(Select p.pid,ct.titlename,p.fname,p.lname,p.birth,GetAgeymd(p.birth,CURDATE())as age,
p.idcard as idcard,h.hno as hno,Right(h.villcode,2) as village
,case when GetAgemonth(p.birth,'2015-11-01')= '9' then '9'
when GetAgemonth(p.birth,'2015-11-01')= '18' then '18'
when GetAgemonth(p.birth,'2015-11-01')= '30' then '30'
when GetAgemonth(p.birth,'2015-11-01')= '42' then '42' else '' end as'เดือน'
,'2015-11-01'AS'เดือนที่อายุถึง'
from person p inner join ctitle ct on p.prename = ct.titlecode
inner join house h on p.pcucodeperson = h.pcucode and p.hcode = h.hcode
where p.typelive in ('1','3')and p.pid not in (select persondeath.pid from persondeath)
and RIGHT(h.villcode,2)<> '00' and GetAgemonth(p.birth,'2015-11-01') in ('9','18','30','42'))
UNION
(Select p.pid,ct.titlename,p.fname,p.lname,p.birth,GetAgeymd(p.birth,CURDATE())as age,
p.idcard as idcard,h.hno as hno,Right(h.villcode,2) as village
,case when GetAgemonth(p.birth,'2015-12-01')= '9' then '9'
when GetAgemonth(p.birth,'2015-12-01')= '18' then '18'
when GetAgemonth(p.birth,'2015-12-01')= '30' then '30'
when GetAgemonth(p.birth,'2015-12-01')= '42' then '42' else '' end as'เดือน'
,'2015-12-01'AS'เดือนที่อายุถึง'
from person p inner join ctitle ct on p.prename = ct.titlecode
inner join house h on p.pcucodeperson = h.pcucode and p.hcode = h.hcode
where p.typelive in ('1','3')and p.pid not in (select persondeath.pid from persondeath)
and RIGHT(h.villcode,2)<> '00' and GetAgemonth(p.birth,'2015-12-01') in ('9','18','30','42'))
UNION
(Select p.pid,ct.titlename,p.fname,p.lname,p.birth,GetAgeymd(p.birth,CURDATE())as age,
p.idcard as idcard,h.hno as hno,Right(h.villcode,2) as village
,case when GetAgemonth(p.birth,'2016-01-01')= '9' then '9'
when GetAgemonth(p.birth,'2016-01-01')= '18' then '18'
when GetAgemonth(p.birth,'2016-01-01')= '30' then '30'
when GetAgemonth(p.birth,'2016-01-01')= '42' then '42' else '' end as'เดือน'
,'2016-01-01'AS'เดือนที่อายุถึง'
from person p inner join ctitle ct on p.prename = ct.titlecode
inner join house h on p.pcucodeperson = h.pcucode and p.hcode = h.hcode
where p.typelive in ('1','3')and p.pid not in (select persondeath.pid from persondeath)
and RIGHT(h.villcode,2)<> '00' and GetAgemonth(p.birth,'2016-01-01') in ('9','18','30','42'))
UNION
(Select p.pid,ct.titlename,p.fname,p.lname,p.birth,GetAgeymd(p.birth,CURDATE())as age,
p.idcard as idcard,h.hno as hno,Right(h.villcode,2) as village
,case when GetAgemonth(p.birth,'2016-02-01')= '9' then '9'
when GetAgemonth(p.birth,'2016-02-01')= '18' then '18'
when GetAgemonth(p.birth,'2016-02-01')= '30' then '30'
when GetAgemonth(p.birth,'2016-02-01')= '42' then '42' else '' end as'เดือน'
,'2016-02-01'AS'เดือนที่อายุถึง'
from person p inner join ctitle ct on p.prename = ct.titlecode
inner join house h on p.pcucodeperson = h.pcucode and p.hcode = h.hcode
where p.typelive in ('1','3')and p.pid not in (select persondeath.pid from persondeath)
and RIGHT(h.villcode,2)<> '00' and GetAgemonth(p.birth,'2016-02-01') in ('9','18','30','42'))
UNION
(Select p.pid,ct.titlename,p.fname,p.lname,p.birth,GetAgeymd(p.birth,CURDATE())as age,
p.idcard as idcard,h.hno as hno,Right(h.villcode,2) as village
,case when GetAgemonth(p.birth,'2016-03-01')= '9' then '9'
when GetAgemonth(p.birth,'2016-03-01')= '18' then '18'
when GetAgemonth(p.birth,'2016-03-01')= '30' then '30'
when GetAgemonth(p.birth,'2016-03-01')= '42' then '42' else '' end as'เดือน'
,'2016-03-01'AS'เดือนที่อายุถึง'
from person p inner join ctitle ct on p.prename = ct.titlecode
inner join house h on p.pcucodeperson = h.pcucode and p.hcode = h.hcode
where p.typelive in ('1','3')and p.pid not in (select persondeath.pid from persondeath)
and RIGHT(h.villcode,2)<> '00' and GetAgemonth(p.birth,'2016-03-01') in ('9','18','30','42'))
UNION
(Select p.pid,ct.titlename,p.fname,p.lname,p.birth,GetAgeymd(p.birth,CURDATE())as age,
p.idcard as idcard,h.hno as hno,Right(h.villcode,2) as village
,case when GetAgemonth(p.birth,'2016-04-01')= '9' then '9'
when GetAgemonth(p.birth,'2016-04-01')= '18' then '18'
when GetAgemonth(p.birth,'2016-04-01')= '30' then '30'
when GetAgemonth(p.birth,'2016-04-01')= '42' then '42' else '' end as'เดือน'
,'2016-04-01'AS'เดือนที่อายุถึง'
from person p inner join ctitle ct on p.prename = ct.titlecode
inner join house h on p.pcucodeperson = h.pcucode and p.hcode = h.hcode
where p.typelive in ('1','3')and p.pid not in (select persondeath.pid from persondeath)
and RIGHT(h.villcode,2)<> '00' and GetAgemonth(p.birth,'2016-04-01') in ('9','18','30','42'))
UNION
(Select p.pid,ct.titlename,p.fname,p.lname,p.birth,GetAgeymd(p.birth,CURDATE())as age,
p.idcard as idcard,h.hno as hno,Right(h.villcode,2) as village
,case when GetAgemonth(p.birth,'2016-05-01')= '9' then '9'
when GetAgemonth(p.birth,'2016-05-01')= '18' then '18'
when GetAgemonth(p.birth,'2016-05-01')= '30' then '30'
when GetAgemonth(p.birth,'2016-05-01')= '42' then '42' else '' end as'เดือน'
,'2016-05-01'AS'เดือนที่อายุถึง'
from person p inner join ctitle ct on p.prename = ct.titlecode
inner join house h on p.pcucodeperson = h.pcucode and p.hcode = h.hcode
where p.typelive in ('1','3')and p.pid not in (select persondeath.pid from persondeath)
and RIGHT(h.villcode,2)<> '00' and GetAgemonth(p.birth,'2016-05-01') in ('9','18','30','42'))
UNION
(Select p.pid,ct.titlename,p.fname,p.lname,p.birth,GetAgeymd(p.birth,CURDATE())as age,
p.idcard as idcard,h.hno as hno,Right(h.villcode,2) as village
,case when GetAgemonth(p.birth,'2016-06-01')= '9' then '9'
when GetAgemonth(p.birth,'2016-06-01')= '18' then '18'
when GetAgemonth(p.birth,'2016-06-01')= '30' then '30'
when GetAgemonth(p.birth,'2016-06-01')= '42' then '42' else '' end as'เดือน'
,'2016-06-01'AS'เดือนที่อายุถึง'
from person p inner join ctitle ct on p.prename = ct.titlecode
inner join house h on p.pcucodeperson = h.pcucode and p.hcode = h.hcode
where p.typelive in ('1','3')and p.pid not in (select persondeath.pid from persondeath)
and RIGHT(h.villcode,2)<> '00' and GetAgemonth(p.birth,'2016-06-01') in ('9','18','30','42'))
UNION
(Select p.pid,ct.titlename,p.fname,p.lname,p.birth,GetAgeymd(p.birth,CURDATE())as age,
p.idcard as idcard,h.hno as hno,Right(h.villcode,2) as village
,case when GetAgemonth(p.birth,'2016-07-01')= '9' then '9'
when GetAgemonth(p.birth,'2016-07-01')= '18' then '18'
when GetAgemonth(p.birth,'2016-07-01')= '30' then '30'
when GetAgemonth(p.birth,'2016-07-01')= '42' then '42' else '' end as'เดือน'
,'2016-07-01'AS'เดือนที่อายุถึง'
from person p inner join ctitle ct on p.prename = ct.titlecode
inner join house h on p.pcucodeperson = h.pcucode and p.hcode = h.hcode
where p.typelive in ('1','3')and p.pid not in (select persondeath.pid from persondeath)
and RIGHT(h.villcode,2)<> '00' and GetAgemonth(p.birth,'2016-07-01') in ('9','18','30','42'))
UNION
(Select p.pid,ct.titlename,p.fname,p.lname,p.birth,GetAgeymd(p.birth,CURDATE())as age,
p.idcard as idcard,h.hno as hno,Right(h.villcode,2) as village
,case when GetAgemonth(p.birth,'2016-08-01')= '9' then '9'
when GetAgemonth(p.birth,'2016-08-01')= '18' then '18'
when GetAgemonth(p.birth,'2016-08-01')= '30' then '30'
when GetAgemonth(p.birth,'2016-08-01')= '42' then '42' else '' end as'เดือน'
,'2016-08-01'AS'เดือนที่อายุถึง'
from person p inner join ctitle ct on p.prename = ct.titlecode
inner join house h on p.pcucodeperson = h.pcucode and p.hcode = h.hcode
where p.typelive in ('1','3')and p.pid not in (select persondeath.pid from persondeath)
and RIGHT(h.villcode,2)<> '00' and GetAgemonth(p.birth,'2016-08-01') in ('9','18','30','42'))
UNION
(Select p.pid,ct.titlename,p.fname,p.lname,p.birth,GetAgeymd(p.birth,CURDATE())as age,
p.idcard as idcard,h.hno as hno,Right(h.villcode,2) as village
,case when GetAgemonth(p.birth,'2016-09-01')= '9' then '9'
when GetAgemonth(p.birth,'2016-09-01')= '18' then '18'
when GetAgemonth(p.birth,'2016-09-01')= '30' then '30'
when GetAgemonth(p.birth,'2016-09-01')= '42' then '42' else '' end as'เดือน'
,'2016-09-01'AS'เดือนที่อายุถึง'
from person p inner join ctitle ct on p.prename = ct.titlecode
inner join house h on p.pcucodeperson = h.pcucode and p.hcode = h.hcode
where p.typelive in ('1','3')and p.pid not in (select persondeath.pid from persondeath)
and RIGHT(h.villcode,2)<> '00' and GetAgemonth(p.birth,'2016-09-01') in ('9','18','30','42'));
..................................................

2.หาคนที่คีย์พัฒนาการผิดปกติ รายด้าน  ตามนี้

...................................................
SET @start ='2015-10-01'; #เริ่ม
SET @end = CURDATE(); # สิ้นสุด

SELECT
f43pp.pcucodeperson,
f43pp.pid,
ctitle.titlename AS 'นำหน้า',
p.fname AS 'ชื่อ',
p.lname AS 'สกุล',
h.hno AS 'เลขที่',
Right(h.villcode,2) AS 'หมู่',
f43pp.dateserv AS 'วันที่ตรวจ',
getagemonth(p.birth,f43pp.dateserv) AS 'อายุขณะตรวจ(เดือน)',
f43pp.ppspecial as 'รหัสพัฒนาการ',
cpp.ppname 'พัฒนาการรายด้าน'
FROM
f43specialpp AS f43pp
INNER JOIN person AS p ON f43pp.pid = p.pid AND f43pp.pcucodeperson = p.pcucodeperson
INNER JOIN cspecialpp AS cpp ON f43pp.ppspecial = cpp.ppcode
INNER JOIN ctitle ON ctitle.titlecode = p.prename
INNER JOIN house h ON p.hcode=h.hcode
WHERE f43pp.dateserv BETWEEN @start AND @end
AND p.typelive IN ('1','3') AND f43pp.ppspecial LIKE '1b2%'
AND f43pp.ppspecial NOT IN ('1B260','1B206','1B203','1B200','1B210','1B213'
,'1B216','1B220','1B223','1B226','1B230','1B233','1B236','1B240','1B243'
,'1B246','1B250','1B252','1B254','1B256','1B258','1B260')
AND p.pid NOT IN (SELECT persondeath.pid FROM persondeath)
GROUP BY f43pp.pid
ORDER BY f43pp.pid;
..................................................

3.คีย์พัฒนาการ  4 กลุ่มวัย ( ตัดซ้ำ 0-5 ปี ออก)

...................................................
SET @start ='2015-10-01'; #เริ่ม
SET @end = CURDATE(); # สิ้รสุด

SELECT
f43pp.pcucodeperson,
f43pp.pid,
ctitle.titlename AS 'นำหน้า',
#p.fname AS 'ชื่อ',
#p.lname AS 'สกุล',
#h.hno AS 'เลขที่',
#Right(h.villcode,2) AS 'หมู่',
f43pp.dateserv AS 'วันที่ตรวจ',
getagemonth(p.birth,f43pp.dateserv) AS 'อายุขณะตรวจ(เดือน)',
f43pp.ppspecial as 'รหัสพัฒนาการ',
cpp.ppname 'พัฒนาการรายด้าน'
FROM
f43specialpp AS f43pp
INNER JOIN person AS p ON f43pp.pid = p.pid AND f43pp.pcucodeperson = p.pcucodeperson
INNER JOIN cspecialpp AS cpp ON f43pp.ppspecial = cpp.ppcode
INNER JOIN ctitle ON ctitle.titlecode = p.prename
INNER JOIN house h ON p.hcode=h.hcode
WHERE f43pp.dateserv BETWEEN @start AND @end
AND p.typelive IN ('1','3') AND f43pp.ppspecial LIKE '1B2%'
AND getagemonth(p.birth,f43pp.dateserv) IN ('9','18','30','42')
AND p.pid NOT IN (SELECT persondeath.pid FROM persondeath)
GROUP BY f43pp.pid
ORDER BY f43pp.dateserv DESC;
.....................................................................................
หมายเหตุ 1 :หากรันแล้ว ในช่อง "พัฒนาการรายด้าน" จะมีข้อความขึ้นต้นด้วยคำว่า "การตรวจคัดกรองพัฒนาการสมวัยฯ"  หากขึ้นต้นด้วยตำอื่นแสดงว่าให้รหัสตรวจพัฒนาการใน 4 กลุ่มวัย  ผิดจ้า
..................................................................................
4.คีย์พัฒนาการ 0-5 ปี (ตัดซ้ำ 4 กลุ่มวัยออก)
....................................................
SET @start ='2015-10-01'; #เริ่ม
SET @end = CURDATE(); # สิ้นสุด

SELECT
f43pp.pcucodeperson,
f43pp.pid,
ctitle.titlename AS 'นำหน้า',
p.fname AS 'ชื่อ',
p.lname AS 'สกุล',
h.hno AS 'เลขที่',
Right(h.villcode,2) AS 'หมู่',
f43pp.dateserv AS 'วันที่ตรวจ',
getagemonth(p.birth,f43pp.dateserv) AS 'อายุขณะตรวจ(เดือน)',
f43pp.ppspecial as 'รหัสพัฒนาการ',
cpp.ppname 'พัฒนาการรายด้าน'
FROM
f43specialpp AS f43pp
INNER JOIN person AS p ON f43pp.pid = p.pid AND f43pp.pcucodeperson = p.pcucodeperson
INNER JOIN cspecialpp AS cpp ON f43pp.ppspecial = cpp.ppcode
INNER JOIN ctitle ON ctitle.titlecode = p.prename
INNER JOIN house h ON p.hcode=h.hcode
WHERE f43pp.dateserv BETWEEN @start AND @end
AND p.typelive IN ('1','3') AND f43pp.ppspecial LIKE '1B2%'
AND getagemonth(p.birth,f43pp.dateserv) NOT IN ('9','18','30','42')
AND p.pid NOT IN (SELECT persondeath.pid FROM persondeath)
GROUP BY f43pp.pid
ORDER BY f43pp.dateserv DESC;
...................................................
หมายเหตุ 2 :หากรันแล้ว ในช่อง "พัฒนาการรายด้าน" จะมีข้อความขึ้นต้นด้วยคำว่า "การตรวจแบบเฝ้าระวังฯ"  หากขึ้นต้นด้วยตำอื่นแสดงว่าให้รหัสตรวจพัฒนาการในกลุ่ม 0-5 ปี ผิดจ้า
(ตัวอย่าง)

5.วิธีการบันทึกพัฒนาการและการให้รหัส
1.คีย์พัฒนาการ 4 กลุ่มวัย คลิก
2.คีย์พัฒนาการ 0-5 ปี คลิก

...................................................................KKK..................................................................


  Scpt ตรวจสอบความครอบคลุม "ผลการคีย์ พัฒนาการ" รายเดือน
>>หลังจากรันข้อมูลแล้วจะได้ ประมาณนี้<<

1.scpt เดือน ตุลาคม 2559  ตามนี้
............................................................
SELECT s.pcucode,s.pid,s.idcard,s.titlename 'คำนำหน้า',s.fname 'ชื่อ'
,s.lname 'สกุล',s.birth 'วดป.เกิด',s.age 'อายุปี',s.hno 'เลขที่',s.villcode 'หมู่ที่',s.interSc 'ช่วงวันที่ที่ต้องคัดกรอง',t.dateserv 'วันที่คัดกรองครั้งแรก',t.codePP 'รหัสคัดกรอง'
FROM ((SELECT p.pcucodeperson AS pcucode ,p.pid ,p.idcard ,ct.titlename ,p.fname ,p.lname
,p.birth ,h.hno ,Right(h.villcode,2) AS villcode ,getagemonth(p.birth,'2016-10-01')AS age
,IF((p.birth BETWEEN '2013-03-01'AND'2013-03-31'),CONCAT_WS('-',(DATE_ADD(p.birth,INTERVAL '3 6' YEAR_MONTH)),
(DATE_ADD(DATE_ADD(p.birth,INTERVAL '3 6' YEAR_MONTH),INTERVAL '30' DAY))),
IF(p.birth BETWEEN '2014-03-01'AND '2014-03-31',CONCAT_WS('-',(DATE_ADD(p.birth,INTERVAL '2 6' YEAR_MONTH)),
(DATE_ADD(DATE_ADD(p.birth,INTERVAL '2 6' YEAR_MONTH),INTERVAL '30' DAY))),
IF(p.birth BETWEEN '2015-03-01'AND '2015-03-31',CONCAT_WS('-',(DATE_ADD(p.birth,INTERVAL '1 6' YEAR_MONTH)),
(DATE_ADD(DATE_ADD(p.birth,INTERVAL '1 6' YEAR_MONTH),INTERVAL '30' DAY))),
IF(p.birth BETWEEN '2015-12-01'AND '2015-12-31',CONCAT_WS('-',(DATE_ADD(p.birth,INTERVAL '9' MONTH)),
(DATE_ADD(DATE_ADD(p.birth,INTERVAL '9' MONTH),INTERVAL '30' DAY))),''))))AS interSc FROM person p INNER JOIN house h ON p.hcode = h.hcode INNER JOIN ctitle ct ON p.prename=ct.titlecode INNER JOIN visit vt ON p.pcucodeperson=vt.pcucodeperson AND p.pid=vt.pid WHERE p.typelive IN ('1','3') AND((p.birth BETWEEN '2013-03-01'AND'2013-03-31')OR (p.birth BETWEEN '2014-03-01'AND '2014-03-31')OR (p.birth BETWEEN '2015-03-01'AND '2015-03-31')OR (p.birth BETWEEN '2015-12-01'AND '2015-12-31'))
GROUP BY vt.pid ORDER BY p.pid,p.birth) AS s LEFT JOIN (SELECT f43pp.pcucodeperson pcucode,f43pp.pid,IF(f43pp.dateserv IS null,'',f43pp.dateserv)AS dateserv,
getagemonth(p.birth,f43pp.dateserv) AS ageScreen,IF(f43pp.ppspecial IS NULL,'',GROUP_CONCAT(f43pp.ppspecial))AS codePP FROM f43specialpp AS f43pp
INNER JOIN person AS p ON f43pp.pid = p.pid AND f43pp.pcucodeperson = p.pcucodeperson
WHERE f43pp.dateserv BETWEEN '2016-09-01' AND '2016-10-30'
AND p.typelive IN ('1','3') AND f43pp.ppspecial LIKE '1B2%' AND((p.birth BETWEEN '2013-03-01'AND'2013-03-31') OR (p.birth BETWEEN '2014-03-01'AND '2014-03-31')OR
(p.birth BETWEEN '2015-03-01'AND '2015-05-31')OR (p.birth BETWEEN '2015-12-01'AND '2015-12-31')) AND p.pid NOT IN (SELECT persondeath.pid FROM persondeath)
GROUP BY f43pp.pid ORDER BY f43pp.dateserv DESC) as t ON s.pid=t.pid );
...........................................................
2.scpt เดือน พฤศจิกายน  2559  ตามนี้
..........................................................
SELECT s.pcucode,s.pid,s.idcard,s.titlename 'คำนำหน้า',s.fname 'ชื่อ'
,s.lname 'สกุล',s.birth 'วดป.เกิด',s.age 'อายุปี',s.hno 'เลขที่',s.villcode 'หมู่ที่',
s.interSc 'ช่วงวันที่ที่ต้องคัดกรอง',t.dateserv 'วันที่คัดกรองครั้งแรก',t.codePP 'รหัสคัดกรอง'
FROM ((SELECT p.pcucodeperson AS pcucode ,p.pid ,p.idcard ,ct.titlename ,p.fname ,p.lname
,p.birth ,h.hno ,Right(h.villcode,2) AS villcode ,getagemonth(p.birth,'2016-10-01')AS age
,IF((p.birth BETWEEN '2013-04-01'AND'2013-05-01'),CONCAT_WS('-',(DATE_ADD(p.birth,INTERVAL '3 6' YEAR_MONTH)),
(DATE_ADD(DATE_ADD(p.birth,INTERVAL '3 6' YEAR_MONTH),INTERVAL '30' DAY))),
IF(p.birth BETWEEN '2014-04-01'AND '2014-05-01',CONCAT_WS('-',(DATE_ADD(p.birth,INTERVAL '2 6' YEAR_MONTH)),
(DATE_ADD(DATE_ADD(p.birth,INTERVAL '2 6' YEAR_MONTH),INTERVAL '30' DAY))),
IF(p.birth BETWEEN '2015-04-01'AND '2015-05-01',CONCAT_WS('-',(DATE_ADD(p.birth,INTERVAL '1 6' YEAR_MONTH)),
(DATE_ADD(DATE_ADD(p.birth,INTERVAL '1 6' YEAR_MONTH),INTERVAL '30' DAY))),
IF(p.birth BETWEEN '2016-01-01'AND '2016-01-31',CONCAT_WS('-',(DATE_ADD(p.birth,INTERVAL '9' MONTH)),
(DATE_ADD(DATE_ADD(p.birth,INTERVAL '9' MONTH),INTERVAL '30' DAY))),''))))AS interSc FROM person p INNER JOIN house h ON p.hcode = h.hcode INNER JOIN ctitle ct ON p.prename=ct.titlecode INNER JOIN visit vt ON p.pcucodeperson=vt.pcucodeperson AND p.pid=vt.pid WHERE p.typelive IN ('1','3') AND((p.birth BETWEEN '2013-04-01'AND'2013-05-01')OR (p.birth BETWEEN '2014-04-01'AND '2014-05-01')OR (p.birth BETWEEN '2015-04-01'AND '2015-05-01')OR (p.birth BETWEEN '2016-01-01'AND '2016-01-31'))
GROUP BY vt.pid ORDER BY p.pid,p.birth) AS s LEFT JOIN (SELECT
f43pp.pcucodeperson pcucode,f43pp.pid,IF(f43pp.dateserv IS null,'',f43pp.dateserv)AS dateserv,
getagemonth(p.birth,f43pp.dateserv) AS ageScreen,IF(f43pp.ppspecial IS NULL,'',GROUP_CONCAT(f43pp.ppspecial))AS codePP
FROM f43specialpp AS f43pp INNER JOIN person AS p ON f43pp.pid = p.pid AND f43pp.pcucodeperson = p.pcucodeperson WHERE f43pp.dateserv BETWEEN '2016-10-01' AND '2016-11-30' AND p.typelive IN ('1','3') AND f43pp.ppspecial LIKE '1B2%'
AND((p.birth BETWEEN '2013-04-01'AND'2013-05-01')OR
(p.birth BETWEEN '2014-04-01'AND '2014-05-01')OR
(p.birth BETWEEN '2015-04-01'AND '2015-05-01')OR
(p.birth BETWEEN '2016-01-01'AND '2016-01-31'))
AND p.pid NOT IN (SELECT persondeath.pid FROM persondeath)
GROUP BY f43pp.pid ORDER BY f43pp.dateserv DESC) as t 
ON s.pid=t.pid );
.........................................................
3.scpt เดือน ธันวาคม 2559 >>>
.........................................................
 "รอ วันที่ 1 ธ.ค.นะจ๊ะ" (จะupdate ให้เป็นเดือนๆไป) เพื่อความชัวร์
........................................................

....อิอิ..


ไม่มีความคิดเห็น:

https://www.blogs

 kllgnsgkj[jtlm'oahd bfldkb'pdojgaojp mfigjdo;sjgaij misjgo;sjagijwo;