BMS-HOSxP Community
HOSxP => การเขียน SQL Script => ข้อความที่เริ่มโดย: Knott ที่ ตุลาคม 10, 2008, 09:25:11 AM
-
ตามรูปครับ อยากได้คำสั่งดึงข้อมูลสรุปค่ารักษาผู้ป่วยในนะครับ รวมถึงสถานะการชำระเงินด้วยครับ ขอบคุณครับ
-
ลองดูครับ
select o.an, i.name, p.name as paidst, sum(o.sum_price) as sum
from opitemrece o
left outer join ipt ip on ip.an=o.an
left outer join income i on i.income=o.income
left outer join paidst p on p.paidst=o.paidst
where o.an="000000002"
group by i.name, p.name
อย่าลืมแก้ an ด้วยครับ