BMS-HOSxP Community
HOSxP => Report Exchange => ข้อความที่เริ่มโดย: prapansak ที่ สิงหาคม 01, 2012, 11:45:42 AM
-
select i.mdc ,SUBSTRING(i.drg,3,2) as dd
from an_stat a
left outer join ipt i on i.an=a.an
where a.dchdate between '2012-01-01'and '2012-01-31 ' and i.mdc=1
-----------------------------------------------------
ติดปัญหาตรงที่ฟิว drg มีตัวเลขทั้งหมด 5 หลักแต่ผมต้องการแค่ 2 หลัก ก็เลยดึงมีแค่สองตัว และอยากได้นำฟิว dd มากำหนดค่า dd < 49 หรือ dd > 49 เพื่อหาคนที่ มีผ่าตัดและไม่มีผ่าตัด
ช่วยแก้ Code ให้ทีนะครับ
ขอบคุณครับ
-
select i.mdc ,SUBSTRING(i.drg,3,2) as dd
from an_stat a
left outer join ipt i on i.an=a.an
where a.dchdate between '2012-01-01'and '2012-01-31 ' and i.mdc=1
-----------------------------------------------------
ติดปัญหาตรงที่ฟิว drg มีตัวเลขทั้งหมด 5 หลักแต่ผมต้องการแค่ 2 หลัก ก็เลยดึงมีแค่สองตัว และอยากได้นำฟิว dd มากำหนดค่า dd < 49 หรือ dd > 49 เพื่อหาคนที่ มีผ่าตัดและไม่มีผ่าตัด
ช่วยแก้ Code ให้ทีนะครับ
ขอบคุณครับ
select i.mdc ,SUBSTRING(i.drg,3,2) as dd, if(SUBSTRING(i.drg,3,2)>49,"N","Y") as op
from an_stat a
left outer join ipt i on i.an=a.an
where a.dchdate between '2012-01-01'and '2012-01-31 '
-
ขอบคุณครับ
-
ผมต้องการนับคนที่มี dd < 50
จะต้องทำยังไงครับ
-
select a.mdc,count(a.mdc) 'Total'
,sum(dd>49) 'NonOP'
,sum(dd<50) 'OP'
from (select i.mdc ,SUBSTRING(i.drg,3,2) as dd
from ipt i
where i.dchdate between '2012-01-01' and '2012-01-31') a
group by a.mdc
order by a.mdc
-
ผมต้องการ ผลรวม ADJRW แยก OR และ NonOR