BMS-HOSxP Community
HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: niwat ที่ ธันวาคม 19, 2007, 09:21:29 AM
-
ขอตัวอย่างคำสั่ง
1.NULL,not null
2.คำสั่งเรียงจากน้อยไปมาก
3.คำสั่งเรียงจากมากไปน้อย
4.sum(sum_price)as sum_sum_price(ถูกเปล่าครับ) ชื่อฟิลด์ sum_price ในตาราง opitemrece
-
select *
from ovst
where an is null << an เป็นค่าว่างครับ not null ก็เหมือนกันครับ
ส่วนคำสั่ง เรียงน้อยไปมาก ใช้เพิ่ม
select *
from ovst
where an is null
order by hn desc << เรียงมากไปน้อยครับ ถ้าน้อยไปมาก ไม่ไมต้องใส่ก็ได้ครับหรือ asc
select sum(sum_price)
from opitemrece
group by vn << จะรวมยอดเงินตามvn ครับ ใช้ sum ,count ต้องมี group by ด้วยครับ
limit 10
ลองหาหัวข้อ คำสั่ง sql ดูก็ได้ครับ ถ้าหากจะเริ่มต้นครับ
-
select v.pdx,count(v.pdx) as pdx_count, i.name as icdname
from an_stat v
left outer join icd101 i on i.code=v.pdx
where v.dchdate between "2003-01-01" and "2003-01-31"
and v.pdx is not null and v.pdx<>"" เป็นการหาค่าผู้ป่วยได้รับการวินิจฉัยและไม่เป็นค่าว่าง
group by v.pdx,i.name
order by pdx_count desc เป็นการเรียงลำดับค่าจากมากไปน้อย
ส่วนหากเราไม่กำหนด มันจะเรียงตามน้อยไปมาก
limit 20
ส่วนข้อ 4 ไม่แน่ใจ